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.
- package/README.md +253 -385
- package/dist/ComputerAgentsClient.d.ts +358 -0
- package/dist/ComputerAgentsClient.js +360 -0
- package/dist/ComputerAgentsClient.js.map +1 -0
- package/dist/cloud/ApiClient.d.ts +62 -0
- package/dist/cloud/ApiClient.js +150 -0
- package/dist/cloud/ApiClient.js.map +1 -0
- package/dist/cloud/resources/AgentsResource.d.ts +39 -0
- package/dist/cloud/resources/AgentsResource.js +58 -0
- package/dist/cloud/resources/AgentsResource.js.map +1 -0
- package/dist/cloud/resources/BudgetResource.d.ts +167 -0
- package/dist/cloud/resources/BudgetResource.js +179 -0
- package/dist/cloud/resources/BudgetResource.js.map +1 -0
- package/dist/cloud/resources/EnvironmentsResource.d.ts +167 -0
- package/dist/cloud/resources/EnvironmentsResource.js +256 -0
- package/dist/cloud/resources/EnvironmentsResource.js.map +1 -0
- package/dist/cloud/resources/FilesResource.d.ts +201 -0
- package/dist/cloud/resources/FilesResource.js +204 -0
- package/dist/cloud/resources/FilesResource.js.map +1 -0
- package/dist/cloud/resources/GitResource.d.ts +28 -0
- package/dist/cloud/resources/GitResource.js +45 -0
- package/dist/cloud/resources/GitResource.js.map +1 -0
- package/dist/cloud/resources/ProjectsResource.d.ts +78 -0
- package/dist/cloud/resources/ProjectsResource.js +117 -0
- package/dist/cloud/resources/ProjectsResource.js.map +1 -0
- package/dist/cloud/resources/RunsResource.d.ts +61 -0
- package/dist/cloud/resources/RunsResource.js +84 -0
- package/dist/cloud/resources/RunsResource.js.map +1 -0
- package/dist/cloud/resources/SchedulesResource.d.ts +58 -0
- package/dist/cloud/resources/SchedulesResource.js +82 -0
- package/dist/cloud/resources/SchedulesResource.js.map +1 -0
- package/dist/cloud/resources/ThreadsResource.d.ts +124 -0
- package/dist/cloud/resources/ThreadsResource.js +178 -0
- package/dist/cloud/resources/ThreadsResource.js.map +1 -0
- package/dist/cloud/resources/index.d.ts +17 -0
- package/dist/cloud/resources/index.js +28 -0
- package/dist/cloud/resources/index.js.map +1 -0
- package/dist/cloud/types.d.ts +676 -0
- package/dist/cloud/types.js +9 -0
- package/dist/cloud/types.js.map +1 -0
- package/dist/index.d.ts +28 -5
- package/dist/index.js +51 -194
- package/dist/index.js.map +1 -1
- package/package.json +25 -24
- package/dist/metadata.d.ts +0 -8
- package/dist/metadata.js +0 -13
- package/dist/metadata.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComputerAgentsClient.js","sourceRoot":"","sources":["../src/ComputerAgentsClient.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;;;AAEH,iDAA8D;AAuBrD,+FAvBW,0BAAc,OAuBX;AArBvB,iDAW2B;AAwG3B;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,oBAAoB;IAC/B;;;OAGG;IACM,GAAG,CAAY;IAExB;;;;;;;;;;;;;;;;;OAiBG;IACM,OAAO,CAAkB;IAElC;;;;;;;;;;;;;OAaG;IACM,YAAY,CAAuB;IAE5C;;;;;;;;;;;;;;OAcG;IACM,MAAM,CAAiB;IAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACM,KAAK,CAAgB;IAE9B;;;;;;;;;;;;;;;;OAgBG;IACM,SAAS,CAAoB;IAEtC;;;;;;;;;;OAUG;IACM,MAAM,CAAiB;IAEhC;;;;;;;;;;OAUG;IACM,OAAO,CAAkB;IAElC;;;;;;;;;;;OAWG;IACM,GAAG,CAAc;IAE1B;;;OAGG;IACM,IAAI,CAAe;IAE5B;;;OAGG;IACM,QAAQ,CAAmB;IAEpC,YAAY,SAAqC,EAAE;QACjD,kDAAkD;QAClD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM;eACvB,OAAO,CAAC,GAAG,CAAC,uBAAuB;eACnC,OAAO,CAAC,GAAG,CAAC,gBAA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I,SAAS;gBAC1C,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,IAAI;gBAC9C,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;QACL,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;IAClC,CAAC;IAED,4EAA4E;IAC5E,sBAAsB;IACtB,4EAA4E;IAE5E;;OAEG;IACH,KAAK,CAAC,MAAM;QACV,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAc,SAAS,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAU,UAAU,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;IAC/B,CAAC;CACF;AA/UD,oDA+UC;AASgC,2CAAW;AAKX,8CAAc"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level API client for the Computer Agents Cloud API
|
|
3
|
+
*
|
|
4
|
+
* This handles HTTP requests, authentication, and error handling.
|
|
5
|
+
* Higher-level resource managers use this client.
|
|
6
|
+
*/
|
|
7
|
+
export interface ApiClientConfig {
|
|
8
|
+
/**
|
|
9
|
+
* API key for authentication
|
|
10
|
+
*/
|
|
11
|
+
apiKey: string;
|
|
12
|
+
/**
|
|
13
|
+
* Base URL for the API
|
|
14
|
+
* @default 'https://api.computer-agents.com'
|
|
15
|
+
*/
|
|
16
|
+
baseUrl?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Request timeout in milliseconds
|
|
19
|
+
* @default 60000 (1 minute)
|
|
20
|
+
*/
|
|
21
|
+
timeout?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Enable debug logging
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
debug?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare class ApiClientError extends Error {
|
|
29
|
+
readonly status: number;
|
|
30
|
+
readonly code?: string | undefined;
|
|
31
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
32
|
+
constructor(message: string, status: number, code?: string | undefined, details?: Record<string, unknown> | undefined);
|
|
33
|
+
}
|
|
34
|
+
export declare class ApiClient {
|
|
35
|
+
private readonly baseUrl;
|
|
36
|
+
private readonly apiKey;
|
|
37
|
+
private readonly timeout;
|
|
38
|
+
private readonly debug;
|
|
39
|
+
constructor(config: ApiClientConfig);
|
|
40
|
+
/**
|
|
41
|
+
* Make an HTTP request to the API
|
|
42
|
+
*/
|
|
43
|
+
request<T>(method: string, path: string, options?: {
|
|
44
|
+
body?: unknown;
|
|
45
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
46
|
+
headers?: Record<string, string>;
|
|
47
|
+
timeout?: number;
|
|
48
|
+
stream?: boolean;
|
|
49
|
+
}): Promise<T>;
|
|
50
|
+
private parseError;
|
|
51
|
+
get<T>(path: string, query?: Record<string, string | number | boolean | undefined>): Promise<T>;
|
|
52
|
+
post<T>(path: string, body?: unknown, options?: {
|
|
53
|
+
stream?: boolean;
|
|
54
|
+
}): Promise<T>;
|
|
55
|
+
patch<T>(path: string, body?: unknown): Promise<T>;
|
|
56
|
+
put<T>(path: string, body?: unknown): Promise<T>;
|
|
57
|
+
delete<T>(path: string): Promise<T>;
|
|
58
|
+
/**
|
|
59
|
+
* Get the base URL
|
|
60
|
+
*/
|
|
61
|
+
getBaseUrl(): string;
|
|
62
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Low-level API client for the Computer Agents Cloud API
|
|
4
|
+
*
|
|
5
|
+
* This handles HTTP requests, authentication, and error handling.
|
|
6
|
+
* Higher-level resource managers use this client.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ApiClient = exports.ApiClientError = void 0;
|
|
10
|
+
class ApiClientError extends Error {
|
|
11
|
+
status;
|
|
12
|
+
code;
|
|
13
|
+
details;
|
|
14
|
+
constructor(message, status, code, details) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.status = status;
|
|
17
|
+
this.code = code;
|
|
18
|
+
this.details = details;
|
|
19
|
+
this.name = 'ApiClientError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.ApiClientError = ApiClientError;
|
|
23
|
+
class ApiClient {
|
|
24
|
+
baseUrl;
|
|
25
|
+
apiKey;
|
|
26
|
+
timeout;
|
|
27
|
+
debug;
|
|
28
|
+
constructor(config) {
|
|
29
|
+
if (!config.apiKey) {
|
|
30
|
+
throw new Error('API key is required. Provide it via:\n' +
|
|
31
|
+
'1. Constructor: new ApiClient({ apiKey: "..." })\n' +
|
|
32
|
+
'2. Environment variable: COMPUTER_AGENTS_API_KEY');
|
|
33
|
+
}
|
|
34
|
+
this.apiKey = config.apiKey;
|
|
35
|
+
this.baseUrl = (config.baseUrl || 'https://api.computer-agents.com').replace(/\/$/, '');
|
|
36
|
+
this.timeout = config.timeout ?? 60000;
|
|
37
|
+
this.debug = config.debug ?? false;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Make an HTTP request to the API
|
|
41
|
+
*/
|
|
42
|
+
async request(method, path, options = {}) {
|
|
43
|
+
const url = new URL(path, this.baseUrl);
|
|
44
|
+
// Add query parameters
|
|
45
|
+
if (options.query) {
|
|
46
|
+
for (const [key, value] of Object.entries(options.query)) {
|
|
47
|
+
if (value !== undefined) {
|
|
48
|
+
url.searchParams.set(key, String(value));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const headers = {
|
|
53
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
54
|
+
...options.headers,
|
|
55
|
+
};
|
|
56
|
+
if (options.body && !options.headers?.['Content-Type']) {
|
|
57
|
+
headers['Content-Type'] = 'application/json';
|
|
58
|
+
}
|
|
59
|
+
if (options.stream) {
|
|
60
|
+
headers['Accept'] = 'text/event-stream';
|
|
61
|
+
}
|
|
62
|
+
if (this.debug) {
|
|
63
|
+
console.log(`[ApiClient] ${method} ${url.toString()}`);
|
|
64
|
+
}
|
|
65
|
+
const controller = new AbortController();
|
|
66
|
+
const timeoutId = setTimeout(() => controller.abort(), options.timeout ?? this.timeout);
|
|
67
|
+
try {
|
|
68
|
+
const response = await fetch(url.toString(), {
|
|
69
|
+
method,
|
|
70
|
+
headers,
|
|
71
|
+
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
72
|
+
signal: controller.signal,
|
|
73
|
+
});
|
|
74
|
+
clearTimeout(timeoutId);
|
|
75
|
+
// For streaming responses, return the response directly
|
|
76
|
+
if (options.stream) {
|
|
77
|
+
if (!response.ok) {
|
|
78
|
+
const error = await this.parseError(response);
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
return response;
|
|
82
|
+
}
|
|
83
|
+
// Parse JSON response
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
const error = await this.parseError(response);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
// Handle 204 No Content
|
|
89
|
+
if (response.status === 204) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
const data = await response.json();
|
|
93
|
+
return data;
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
clearTimeout(timeoutId);
|
|
97
|
+
if (error instanceof ApiClientError) {
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
101
|
+
throw new ApiClientError(`Request timeout after ${options.timeout ?? this.timeout}ms`, 408, 'TIMEOUT');
|
|
102
|
+
}
|
|
103
|
+
throw new ApiClientError(error instanceof Error ? error.message : 'Unknown error', 500, 'NETWORK_ERROR');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async parseError(response) {
|
|
107
|
+
let errorData;
|
|
108
|
+
try {
|
|
109
|
+
errorData = await response.json();
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
errorData = {
|
|
113
|
+
error: response.statusText,
|
|
114
|
+
message: `HTTP ${response.status}`,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return new ApiClientError(errorData.message || errorData.error, response.status, errorData.code, errorData.details);
|
|
118
|
+
}
|
|
119
|
+
// Convenience methods
|
|
120
|
+
async get(path, query) {
|
|
121
|
+
return this.request('GET', path, { query });
|
|
122
|
+
}
|
|
123
|
+
async post(path, body, options) {
|
|
124
|
+
return this.request('POST', path, { body, ...options });
|
|
125
|
+
}
|
|
126
|
+
async patch(path, body) {
|
|
127
|
+
return this.request('PATCH', path, { body });
|
|
128
|
+
}
|
|
129
|
+
async put(path, body) {
|
|
130
|
+
return this.request('PUT', path, { body });
|
|
131
|
+
}
|
|
132
|
+
async delete(path) {
|
|
133
|
+
return this.request('DELETE', path);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Get the base URL
|
|
137
|
+
*/
|
|
138
|
+
getBaseUrl() {
|
|
139
|
+
return this.baseUrl;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Get the API key (for special requests like FormData)
|
|
143
|
+
* @internal
|
|
144
|
+
*/
|
|
145
|
+
getApiKey() {
|
|
146
|
+
return this.apiKey;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.ApiClient = ApiClient;
|
|
150
|
+
//# sourceMappingURL=ApiClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiClient.js","sourceRoot":"","sources":["../../src/cloud/ApiClient.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA6BH,MAAa,cAAe,SAAQ,KAAK;IAGrB;IACA;IACA;IAJlB,YACE,OAAe,EACC,MAAc,EACd,IAAa,EACb,OAAiC;QAEjD,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAS;QACb,YAA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,SAAS,CAAC,OAAO,IAAI,SAAS,CAAC,KAAK,EACpC,QAAQ,CAAC,MAAM,EACf,SAAS,CAAC,IAAI,EACd,SAAS,CAAC,OAAO,CAClB,CAAC;IACJ,CAAC;IAED,sBAAsB;IACtB,KAAK,CAAC,GAAG,CAAI,IAAY,EAAE,KAA6D;QACtF,OAAO,IAAI,CAAC,OAAO,CAAI,KAAK,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,IAAI,CAAI,IAAY,EAAE,IAAc,EAAE,OAA8B;QACxE,OAAO,IAAI,CAAC,OAAO,CAAI,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,KAAK,CAAI,IAAY,EAAE,IAAc;QACzC,OAAO,IAAI,CAAC,OAAO,CAAI,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,GAAG,CAAI,IAAY,EAAE,IAAc;QACvC,OAAO,IAAI,CAAC,OAAO,CAAI,KAAK,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,MAAM,CAAI,IAAY;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAI,QAAQ,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAnLD,8BAmLC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agents Resource Manager
|
|
3
|
+
*
|
|
4
|
+
* Handles agent configuration including CRUD operations
|
|
5
|
+
* and model/skill configuration.
|
|
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 { CloudAgent, CreateAgentParams, UpdateAgentParams } from '../types';
|
|
12
|
+
export declare class AgentsResource {
|
|
13
|
+
private readonly client;
|
|
14
|
+
constructor(client: ApiClient);
|
|
15
|
+
/**
|
|
16
|
+
* Create a new agent
|
|
17
|
+
*
|
|
18
|
+
* Project is determined automatically from the API key.
|
|
19
|
+
*/
|
|
20
|
+
create(params: CreateAgentParams): Promise<CloudAgent>;
|
|
21
|
+
/**
|
|
22
|
+
* List all agents
|
|
23
|
+
*
|
|
24
|
+
* Project is determined automatically from the API key.
|
|
25
|
+
*/
|
|
26
|
+
list(): Promise<CloudAgent[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Get an agent by ID
|
|
29
|
+
*/
|
|
30
|
+
get(agentId: string): Promise<CloudAgent>;
|
|
31
|
+
/**
|
|
32
|
+
* Update an agent
|
|
33
|
+
*/
|
|
34
|
+
update(agentId: string, params: UpdateAgentParams): Promise<CloudAgent>;
|
|
35
|
+
/**
|
|
36
|
+
* Delete an agent
|
|
37
|
+
*/
|
|
38
|
+
delete(agentId: string, hard?: boolean): Promise<void>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Agents Resource Manager
|
|
4
|
+
*
|
|
5
|
+
* Handles agent configuration including CRUD operations
|
|
6
|
+
* and model/skill configuration.
|
|
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.AgentsResource = void 0;
|
|
13
|
+
class AgentsResource {
|
|
14
|
+
client;
|
|
15
|
+
constructor(client) {
|
|
16
|
+
this.client = client;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create a new agent
|
|
20
|
+
*
|
|
21
|
+
* Project is determined automatically from the API key.
|
|
22
|
+
*/
|
|
23
|
+
async create(params) {
|
|
24
|
+
const response = await this.client.post(`/agents`, params);
|
|
25
|
+
return response.agent;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* List all agents
|
|
29
|
+
*
|
|
30
|
+
* Project is determined automatically from the API key.
|
|
31
|
+
*/
|
|
32
|
+
async list() {
|
|
33
|
+
const response = await this.client.get(`/agents`);
|
|
34
|
+
return response.data;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get an agent by ID
|
|
38
|
+
*/
|
|
39
|
+
async get(agentId) {
|
|
40
|
+
const response = await this.client.get(`/agents/${agentId}`);
|
|
41
|
+
return response.agent;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Update an agent
|
|
45
|
+
*/
|
|
46
|
+
async update(agentId, params) {
|
|
47
|
+
const response = await this.client.patch(`/agents/${agentId}`, params);
|
|
48
|
+
return response.agent;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Delete an agent
|
|
52
|
+
*/
|
|
53
|
+
async delete(agentId, hard = false) {
|
|
54
|
+
await this.client.delete(`/agents/${agentId}${hard ? '?hard=true' : ''}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.AgentsResource = AgentsResource;
|
|
58
|
+
//# sourceMappingURL=AgentsResource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentsResource.js","sourceRoot":"","sources":["../../../src/cloud/resources/AgentsResource.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AASH,MAAa,cAAc;IACI;IAA7B,YAA6B,MAAiB;QAAjB,WAAM,GAAN,MAAM,CAAW;IAAG,CAAC;IAElD;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,MAAyB;QACpC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACrC,SAAS,EACT,MAAM,CACP,CAAC;QACF,OAAO,QAAQ,CAAC,KAAK,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CACpC,SAAS,CACV,CAAC;QACF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,OAAe;QACvB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CACpC,WAAW,OAAO,EAAE,CACrB,CAAC;QACF,OAAO,QAAQ,CAAC,KAAK,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CACV,OAAe,EACf,MAAyB;QAEzB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CACtC,WAAW,OAAO,EAAE,EACpB,MAAM,CACP,CAAC;QACF,OAAO,QAAQ,CAAC,KAAK,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,OAAe,EAAE,OAAgB,KAAK;QACjD,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CACtB,WAAW,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAChD,CAAC;IACJ,CAAC;CACF;AA5DD,wCA4DC"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Budget & Billing Resource Manager
|
|
3
|
+
*
|
|
4
|
+
* Handles budget management, billing records, and usage tracking.
|
|
5
|
+
*
|
|
6
|
+
* Note: projectId is now embedded in the API key, so routes use
|
|
7
|
+
* simplified paths without /projects/:projectId prefix.
|
|
8
|
+
*/
|
|
9
|
+
import type { ApiClient } from '../ApiClient';
|
|
10
|
+
import type { BudgetStatus, CanExecuteResult, IncreaseBudgetParams, IncreaseBudgetResult, BillingRecord, ListBillingRecordsParams, BillingAccount, UsageStats, UsageStatsParams } from '../types';
|
|
11
|
+
export declare class BudgetResource {
|
|
12
|
+
private readonly client;
|
|
13
|
+
constructor(client: ApiClient);
|
|
14
|
+
/**
|
|
15
|
+
* Get budget status via costs summary
|
|
16
|
+
*
|
|
17
|
+
* Project is determined automatically from the API key.
|
|
18
|
+
*/
|
|
19
|
+
getStatus(): Promise<BudgetStatus>;
|
|
20
|
+
/**
|
|
21
|
+
* Check if execution is allowed given current budget
|
|
22
|
+
*
|
|
23
|
+
* Note: This is a convenience method that always returns true
|
|
24
|
+
* since the backend handles budget checks during execution.
|
|
25
|
+
*/
|
|
26
|
+
canExecute(estimatedCost?: number): Promise<CanExecuteResult>;
|
|
27
|
+
/**
|
|
28
|
+
* Increase budget
|
|
29
|
+
*
|
|
30
|
+
* Project is determined automatically from the API key.
|
|
31
|
+
*/
|
|
32
|
+
increase(params: IncreaseBudgetParams): Promise<IncreaseBudgetResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Get billing records
|
|
35
|
+
*
|
|
36
|
+
* Project is determined automatically from the API key.
|
|
37
|
+
*/
|
|
38
|
+
getRecords(params?: ListBillingRecordsParams): Promise<{
|
|
39
|
+
records: BillingRecord[];
|
|
40
|
+
pagination: {
|
|
41
|
+
total: number;
|
|
42
|
+
limit: number;
|
|
43
|
+
offset: number;
|
|
44
|
+
};
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Get billing summary
|
|
48
|
+
*
|
|
49
|
+
* Project is determined automatically from the API key.
|
|
50
|
+
*/
|
|
51
|
+
getSummary(): Promise<{
|
|
52
|
+
totalSpent: number;
|
|
53
|
+
periodStart: string;
|
|
54
|
+
periodEnd: string;
|
|
55
|
+
runCount: number;
|
|
56
|
+
tokenCount: number;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Get daily spending breakdown
|
|
60
|
+
*
|
|
61
|
+
* Project is determined automatically from the API key.
|
|
62
|
+
*/
|
|
63
|
+
getDailySpending(): Promise<{
|
|
64
|
+
days: Array<{
|
|
65
|
+
date: string;
|
|
66
|
+
cost: number;
|
|
67
|
+
runs: number;
|
|
68
|
+
tokens: number;
|
|
69
|
+
}>;
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* Record MCP server usage
|
|
73
|
+
*
|
|
74
|
+
* Project is determined automatically from the API key.
|
|
75
|
+
*/
|
|
76
|
+
recordMcpUsage(params: {
|
|
77
|
+
serverType: 'deep_research' | 'nano_banana';
|
|
78
|
+
referenceId?: string;
|
|
79
|
+
metadata?: Record<string, unknown>;
|
|
80
|
+
}): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Get available top-up options
|
|
83
|
+
*
|
|
84
|
+
* Project is determined automatically from the API key.
|
|
85
|
+
*/
|
|
86
|
+
getTopUpOptions(): Promise<{
|
|
87
|
+
options: Array<{
|
|
88
|
+
amount: number;
|
|
89
|
+
variantId: string;
|
|
90
|
+
label: string;
|
|
91
|
+
}>;
|
|
92
|
+
}>;
|
|
93
|
+
/**
|
|
94
|
+
* Create a checkout session for adding funds
|
|
95
|
+
*
|
|
96
|
+
* Project is determined automatically from the API key.
|
|
97
|
+
*/
|
|
98
|
+
createCheckout(params: {
|
|
99
|
+
variantId: string;
|
|
100
|
+
userEmail?: string;
|
|
101
|
+
userName?: string;
|
|
102
|
+
redirectUrl?: string;
|
|
103
|
+
}): Promise<{
|
|
104
|
+
checkoutUrl: string;
|
|
105
|
+
}>;
|
|
106
|
+
/**
|
|
107
|
+
* Get payment integration status
|
|
108
|
+
*
|
|
109
|
+
* Project is determined automatically from the API key.
|
|
110
|
+
*/
|
|
111
|
+
getPaymentStatus(): Promise<{
|
|
112
|
+
configured: boolean;
|
|
113
|
+
provider?: string;
|
|
114
|
+
pendingPayments: number;
|
|
115
|
+
}>;
|
|
116
|
+
}
|
|
117
|
+
export declare class BillingResource {
|
|
118
|
+
private readonly client;
|
|
119
|
+
constructor(client: ApiClient);
|
|
120
|
+
/**
|
|
121
|
+
* Get billing account information
|
|
122
|
+
*/
|
|
123
|
+
getAccount(): Promise<BillingAccount>;
|
|
124
|
+
/**
|
|
125
|
+
* Get usage statistics
|
|
126
|
+
*/
|
|
127
|
+
getStats(params?: UsageStatsParams): Promise<UsageStats>;
|
|
128
|
+
/**
|
|
129
|
+
* Get workspace usage breakdown
|
|
130
|
+
*/
|
|
131
|
+
getWorkspaceUsage(): Promise<{
|
|
132
|
+
workspaces: Array<{
|
|
133
|
+
projectId: string;
|
|
134
|
+
projectName: string;
|
|
135
|
+
storageBytes: number;
|
|
136
|
+
fileCount: number;
|
|
137
|
+
lastAccessed: string;
|
|
138
|
+
}>;
|
|
139
|
+
total: {
|
|
140
|
+
storageBytes: number;
|
|
141
|
+
projectCount: number;
|
|
142
|
+
};
|
|
143
|
+
}>;
|
|
144
|
+
/**
|
|
145
|
+
* Get transaction history
|
|
146
|
+
*/
|
|
147
|
+
getTransactions(params?: {
|
|
148
|
+
from?: string;
|
|
149
|
+
to?: string;
|
|
150
|
+
type?: string;
|
|
151
|
+
limit?: number;
|
|
152
|
+
offset?: number;
|
|
153
|
+
}): Promise<{
|
|
154
|
+
transactions: Array<{
|
|
155
|
+
id: string;
|
|
156
|
+
type: string;
|
|
157
|
+
amount: number;
|
|
158
|
+
description?: string;
|
|
159
|
+
createdAt: string;
|
|
160
|
+
}>;
|
|
161
|
+
pagination: {
|
|
162
|
+
total: number;
|
|
163
|
+
limit: number;
|
|
164
|
+
offset: number;
|
|
165
|
+
};
|
|
166
|
+
}>;
|
|
167
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Budget & Billing Resource Manager
|
|
4
|
+
*
|
|
5
|
+
* Handles budget management, billing records, and usage tracking.
|
|
6
|
+
*
|
|
7
|
+
* Note: projectId is now embedded in the API key, so routes use
|
|
8
|
+
* simplified paths without /projects/:projectId prefix.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.BillingResource = exports.BudgetResource = void 0;
|
|
12
|
+
class BudgetResource {
|
|
13
|
+
client;
|
|
14
|
+
constructor(client) {
|
|
15
|
+
this.client = client;
|
|
16
|
+
}
|
|
17
|
+
// =========================================================================
|
|
18
|
+
// Budget Operations
|
|
19
|
+
// =========================================================================
|
|
20
|
+
/**
|
|
21
|
+
* Get budget status via costs summary
|
|
22
|
+
*
|
|
23
|
+
* Project is determined automatically from the API key.
|
|
24
|
+
*/
|
|
25
|
+
async getStatus() {
|
|
26
|
+
// Use costs/summary endpoint since /budget doesn't exist
|
|
27
|
+
const response = await this.client.get(`/costs/summary`);
|
|
28
|
+
// Map to BudgetStatus format
|
|
29
|
+
return {
|
|
30
|
+
balance: 0, // Not available from this endpoint
|
|
31
|
+
spent: response.totals.totalCost,
|
|
32
|
+
limit: 0, // Not available
|
|
33
|
+
remaining: 0, // Not available
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Check if execution is allowed given current budget
|
|
38
|
+
*
|
|
39
|
+
* Note: This is a convenience method that always returns true
|
|
40
|
+
* since the backend handles budget checks during execution.
|
|
41
|
+
*/
|
|
42
|
+
async canExecute(estimatedCost) {
|
|
43
|
+
// Budget checks are handled server-side during execution
|
|
44
|
+
return {
|
|
45
|
+
canExecute: true,
|
|
46
|
+
reason: 'Budget checks performed during execution',
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Increase budget
|
|
51
|
+
*
|
|
52
|
+
* Project is determined automatically from the API key.
|
|
53
|
+
*/
|
|
54
|
+
async increase(params) {
|
|
55
|
+
const response = await this.client.post(`/budget/increase`, params);
|
|
56
|
+
return response;
|
|
57
|
+
}
|
|
58
|
+
// =========================================================================
|
|
59
|
+
// Billing Records
|
|
60
|
+
// =========================================================================
|
|
61
|
+
/**
|
|
62
|
+
* Get billing records
|
|
63
|
+
*
|
|
64
|
+
* Project is determined automatically from the API key.
|
|
65
|
+
*/
|
|
66
|
+
async getRecords(params = {}) {
|
|
67
|
+
const response = await this.client.get(`/billing/records`, {
|
|
68
|
+
limit: params.limit,
|
|
69
|
+
offset: params.offset,
|
|
70
|
+
since: params.since,
|
|
71
|
+
until: params.until,
|
|
72
|
+
type: params.type,
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
records: response.data,
|
|
76
|
+
pagination: {
|
|
77
|
+
total: response.total_count,
|
|
78
|
+
limit: params.limit || 50,
|
|
79
|
+
offset: params.offset || 0,
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get billing summary
|
|
85
|
+
*
|
|
86
|
+
* Project is determined automatically from the API key.
|
|
87
|
+
*/
|
|
88
|
+
async getSummary() {
|
|
89
|
+
const response = await this.client.get(`/billing/summary`);
|
|
90
|
+
return response;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get daily spending breakdown
|
|
94
|
+
*
|
|
95
|
+
* Project is determined automatically from the API key.
|
|
96
|
+
*/
|
|
97
|
+
async getDailySpending() {
|
|
98
|
+
const response = await this.client.get(`/billing/daily`);
|
|
99
|
+
return response;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Record MCP server usage
|
|
103
|
+
*
|
|
104
|
+
* Project is determined automatically from the API key.
|
|
105
|
+
*/
|
|
106
|
+
async recordMcpUsage(params) {
|
|
107
|
+
await this.client.post(`/billing/mcp-usage`, params);
|
|
108
|
+
}
|
|
109
|
+
// =========================================================================
|
|
110
|
+
// Payment Integration
|
|
111
|
+
// =========================================================================
|
|
112
|
+
/**
|
|
113
|
+
* Get available top-up options
|
|
114
|
+
*
|
|
115
|
+
* Project is determined automatically from the API key.
|
|
116
|
+
*/
|
|
117
|
+
async getTopUpOptions() {
|
|
118
|
+
const response = await this.client.get(`/budget/topup-options`);
|
|
119
|
+
return response;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Create a checkout session for adding funds
|
|
123
|
+
*
|
|
124
|
+
* Project is determined automatically from the API key.
|
|
125
|
+
*/
|
|
126
|
+
async createCheckout(params) {
|
|
127
|
+
const response = await this.client.post(`/budget/checkout`, params);
|
|
128
|
+
return response;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Get payment integration status
|
|
132
|
+
*
|
|
133
|
+
* Project is determined automatically from the API key.
|
|
134
|
+
*/
|
|
135
|
+
async getPaymentStatus() {
|
|
136
|
+
const response = await this.client.get(`/budget/payment-status`);
|
|
137
|
+
return response;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.BudgetResource = BudgetResource;
|
|
141
|
+
class BillingResource {
|
|
142
|
+
client;
|
|
143
|
+
constructor(client) {
|
|
144
|
+
this.client = client;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Get billing account information
|
|
148
|
+
*/
|
|
149
|
+
async getAccount() {
|
|
150
|
+
const response = await this.client.get('/billing/account');
|
|
151
|
+
return response.account;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Get usage statistics
|
|
155
|
+
*/
|
|
156
|
+
async getStats(params = {}) {
|
|
157
|
+
const response = await this.client.get('/billing/stats', {
|
|
158
|
+
period: params.period,
|
|
159
|
+
breakdown: params.breakdown,
|
|
160
|
+
});
|
|
161
|
+
return response.stats;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Get workspace usage breakdown
|
|
165
|
+
*/
|
|
166
|
+
async getWorkspaceUsage() {
|
|
167
|
+
const response = await this.client.get('/billing/usage/workspace');
|
|
168
|
+
return response;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Get transaction history
|
|
172
|
+
*/
|
|
173
|
+
async getTransactions(params) {
|
|
174
|
+
const response = await this.client.get('/billing/transactions', params);
|
|
175
|
+
return response;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
exports.BillingResource = BillingResource;
|
|
179
|
+
//# sourceMappingURL=BudgetResource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BudgetResource.js","sourceRoot":"","sources":["../../../src/cloud/resources/BudgetResource.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAeH,MAAa,cAAc;IACI;IAA7B,YAA6B,MAAiB;QAAjB,WAAM,GAAN,MAAM,CAAW;IAAG,CAAC;IAElD,4EAA4E;IAC5E,oBAAoB;IACpB,4EAA4E;IAE5E;;;;OAIG;IACH,KAAK,CAAC,SAAS;QACb,yDAAyD;QACzD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAQnC,gBAAgB,CAAC,CAAC;QAErB,6BAA6B;QAC7B,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,mCAAmC;YAC/C,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS;YAChC,KAAK,EAAE,CAAC,EAAE,gBAAgB;YAC1B,SAAS,EAAE,CAAC,EAAE,gBAAgB;SAC/B,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,UAAU,CAAC,aAAsB;QACrC,yDAAyD;QACzD,OAAO;YACL,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,0CAA0C;SACnD,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CACZ,MAA4B;QAE5B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACrC,kBAAkB,EAClB,MAAM,CACP,CAAC;QACF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,4EAA4E;IAC5E,kBAAkB;IAClB,4EAA4E;IAE5E;;;;OAIG;IACH,KAAK,CAAC,UAAU,CACd,SAAmC,EAAE;QAKrC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAKnC,kBAAkB,EAAE;YACrB,KAAK,EAAE,MA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