computer-agents 1.0.3 → 1.1.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 +357 -0
- package/dist/ComputerAgentsClient.js +359 -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 +665 -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 +23 -25
- package/dist/metadata.d.ts +0 -8
- package/dist/metadata.js +0 -13
- package/dist/metadata.js.map +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schedules Resource Manager
|
|
3
|
+
*
|
|
4
|
+
* Handles scheduled task management including CRUD operations
|
|
5
|
+
* and schedule control (trigger/enable/disable).
|
|
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 { Schedule, CreateScheduleParams, UpdateScheduleParams } from '../types';
|
|
12
|
+
export declare class SchedulesResource {
|
|
13
|
+
private readonly client;
|
|
14
|
+
constructor(client: ApiClient);
|
|
15
|
+
/**
|
|
16
|
+
* Create a new schedule
|
|
17
|
+
*
|
|
18
|
+
* Project is determined automatically from the API key.
|
|
19
|
+
*/
|
|
20
|
+
create(params: CreateScheduleParams): Promise<Schedule>;
|
|
21
|
+
/**
|
|
22
|
+
* List all schedules
|
|
23
|
+
*
|
|
24
|
+
* Project is determined automatically from the API key.
|
|
25
|
+
*/
|
|
26
|
+
list(params?: {
|
|
27
|
+
enabled?: boolean;
|
|
28
|
+
limit?: number;
|
|
29
|
+
offset?: number;
|
|
30
|
+
}): Promise<Schedule[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Get a schedule by ID
|
|
33
|
+
*/
|
|
34
|
+
get(scheduleId: string): Promise<Schedule>;
|
|
35
|
+
/**
|
|
36
|
+
* Update a schedule
|
|
37
|
+
*/
|
|
38
|
+
update(scheduleId: string, params: UpdateScheduleParams): Promise<Schedule>;
|
|
39
|
+
/**
|
|
40
|
+
* Delete a schedule
|
|
41
|
+
*/
|
|
42
|
+
delete(scheduleId: string): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Manually trigger a schedule
|
|
45
|
+
*/
|
|
46
|
+
trigger(scheduleId: string): Promise<{
|
|
47
|
+
runId: string;
|
|
48
|
+
triggered: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Enable a schedule
|
|
52
|
+
*/
|
|
53
|
+
enable(scheduleId: string): Promise<Schedule>;
|
|
54
|
+
/**
|
|
55
|
+
* Disable a schedule
|
|
56
|
+
*/
|
|
57
|
+
disable(scheduleId: string): Promise<Schedule>;
|
|
58
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Schedules Resource Manager
|
|
4
|
+
*
|
|
5
|
+
* Handles scheduled task management including CRUD operations
|
|
6
|
+
* and schedule control (trigger/enable/disable).
|
|
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.SchedulesResource = void 0;
|
|
13
|
+
class SchedulesResource {
|
|
14
|
+
client;
|
|
15
|
+
constructor(client) {
|
|
16
|
+
this.client = client;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create a new schedule
|
|
20
|
+
*
|
|
21
|
+
* Project is determined automatically from the API key.
|
|
22
|
+
*/
|
|
23
|
+
async create(params) {
|
|
24
|
+
const response = await this.client.post(`/schedules`, params);
|
|
25
|
+
return response.schedule;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* List all schedules
|
|
29
|
+
*
|
|
30
|
+
* Project is determined automatically from the API key.
|
|
31
|
+
*/
|
|
32
|
+
async list(params) {
|
|
33
|
+
const response = await this.client.get(`/schedules`, params);
|
|
34
|
+
return response.data;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get a schedule by ID
|
|
38
|
+
*/
|
|
39
|
+
async get(scheduleId) {
|
|
40
|
+
const response = await this.client.get(`/schedules/${scheduleId}`);
|
|
41
|
+
return response.schedule;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Update a schedule
|
|
45
|
+
*/
|
|
46
|
+
async update(scheduleId, params) {
|
|
47
|
+
const response = await this.client.patch(`/schedules/${scheduleId}`, params);
|
|
48
|
+
return response.schedule;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Delete a schedule
|
|
52
|
+
*/
|
|
53
|
+
async delete(scheduleId) {
|
|
54
|
+
await this.client.delete(`/schedules/${scheduleId}`);
|
|
55
|
+
}
|
|
56
|
+
// =========================================================================
|
|
57
|
+
// Schedule Control
|
|
58
|
+
// =========================================================================
|
|
59
|
+
/**
|
|
60
|
+
* Manually trigger a schedule
|
|
61
|
+
*/
|
|
62
|
+
async trigger(scheduleId) {
|
|
63
|
+
const response = await this.client.post(`/schedules/${scheduleId}/trigger`);
|
|
64
|
+
return response;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Enable a schedule
|
|
68
|
+
*/
|
|
69
|
+
async enable(scheduleId) {
|
|
70
|
+
const response = await this.client.patch(`/schedules/${scheduleId}/enable`);
|
|
71
|
+
return response.schedule;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Disable a schedule
|
|
75
|
+
*/
|
|
76
|
+
async disable(scheduleId) {
|
|
77
|
+
const response = await this.client.patch(`/schedules/${scheduleId}/disable`);
|
|
78
|
+
return response.schedule;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.SchedulesResource = SchedulesResource;
|
|
82
|
+
//# sourceMappingURL=SchedulesResource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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kB;QAI9B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAGpC,cAAc,UAAU,UAAU,CAAC,CAAC;QACvC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,UAAkB;QAC7B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CACtC,cAAc,UAAU,SAAS,CAClC,CAAC;QACF,OAAO,QAAQ,CAAC,QAAQ,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,UAAkB;QAC9B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CACtC,cAAc,UAAU,UAAU,CACnC,CAAC;QACF,OAAO,QAAQ,CAAC,QAAQ,CAAC;IAC3B,CAAC;CACF;AArGD,8CAqGC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Threads Resource Manager
|
|
3
|
+
*
|
|
4
|
+
* Handles conversation threads including CRUD operations,
|
|
5
|
+
* message execution with SSE streaming, and conversation history.
|
|
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 { Thread, CreateThreadParams, UpdateThreadParams, ListThreadsParams, SendMessageParams, ThreadMessage, MessageStreamEvent } from '../types';
|
|
12
|
+
/**
|
|
13
|
+
* Callback for handling streaming events
|
|
14
|
+
*/
|
|
15
|
+
export type StreamEventCallback = (event: MessageStreamEvent) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Options for sendMessage
|
|
18
|
+
*/
|
|
19
|
+
export interface SendMessageOptions extends SendMessageParams {
|
|
20
|
+
/**
|
|
21
|
+
* Callback for handling streaming events
|
|
22
|
+
*/
|
|
23
|
+
onEvent?: StreamEventCallback;
|
|
24
|
+
/**
|
|
25
|
+
* Timeout for the entire streaming operation
|
|
26
|
+
* @default 600000 (10 minutes)
|
|
27
|
+
*/
|
|
28
|
+
timeout?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Result from sendMessage
|
|
32
|
+
*/
|
|
33
|
+
export interface SendMessageResult {
|
|
34
|
+
/**
|
|
35
|
+
* The final response content
|
|
36
|
+
*/
|
|
37
|
+
content: string;
|
|
38
|
+
/**
|
|
39
|
+
* Run details if available
|
|
40
|
+
*/
|
|
41
|
+
run?: {
|
|
42
|
+
id: string;
|
|
43
|
+
status: string;
|
|
44
|
+
tokens?: {
|
|
45
|
+
input: number;
|
|
46
|
+
output: number;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* All events received during streaming
|
|
51
|
+
*/
|
|
52
|
+
events: MessageStreamEvent[];
|
|
53
|
+
}
|
|
54
|
+
export declare class ThreadsResource {
|
|
55
|
+
private readonly client;
|
|
56
|
+
constructor(client: ApiClient);
|
|
57
|
+
/**
|
|
58
|
+
* Create a new thread
|
|
59
|
+
*
|
|
60
|
+
* Project is determined automatically from the API key.
|
|
61
|
+
*/
|
|
62
|
+
create(params: CreateThreadParams): Promise<Thread>;
|
|
63
|
+
/**
|
|
64
|
+
* List threads
|
|
65
|
+
*
|
|
66
|
+
* Project is determined automatically from the API key.
|
|
67
|
+
*/
|
|
68
|
+
list(params?: ListThreadsParams): Promise<{
|
|
69
|
+
data: Thread[];
|
|
70
|
+
hasMore: boolean;
|
|
71
|
+
total: number;
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Get a thread by ID with full message history
|
|
75
|
+
*/
|
|
76
|
+
get(threadId: string): Promise<Thread>;
|
|
77
|
+
/**
|
|
78
|
+
* Update a thread
|
|
79
|
+
*/
|
|
80
|
+
update(threadId: string, params: UpdateThreadParams): Promise<Thread>;
|
|
81
|
+
/**
|
|
82
|
+
* Delete a thread (soft delete)
|
|
83
|
+
*/
|
|
84
|
+
delete(threadId: string): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Get message history for a thread
|
|
87
|
+
*/
|
|
88
|
+
getMessages(threadId: string): Promise<{
|
|
89
|
+
data: ThreadMessage[];
|
|
90
|
+
hasMore: boolean;
|
|
91
|
+
total: number;
|
|
92
|
+
}>;
|
|
93
|
+
/**
|
|
94
|
+
* Send a message to a thread and stream the response
|
|
95
|
+
*
|
|
96
|
+
* This method handles SSE streaming from the API and returns
|
|
97
|
+
* the complete result when finished.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const result = await client.threads.sendMessage(
|
|
102
|
+
* 'thread_456',
|
|
103
|
+
* {
|
|
104
|
+
* content: 'Create a REST API with Flask',
|
|
105
|
+
* onEvent: (event) => {
|
|
106
|
+
* if (event.type === 'response.item.completed') {
|
|
107
|
+
* console.log('Item:', event.item);
|
|
108
|
+
* }
|
|
109
|
+
* }
|
|
110
|
+
* }
|
|
111
|
+
* );
|
|
112
|
+
* console.log('Final response:', result.content);
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
sendMessage(threadId: string, options: SendMessageOptions): Promise<SendMessageResult>;
|
|
116
|
+
/**
|
|
117
|
+
* Cancel an in-progress message execution
|
|
118
|
+
*/
|
|
119
|
+
cancel(threadId: string): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* Resume a thread (useful after server restart)
|
|
122
|
+
*/
|
|
123
|
+
resume(threadId: string): Promise<Thread>;
|
|
124
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Threads Resource Manager
|
|
4
|
+
*
|
|
5
|
+
* Handles conversation threads including CRUD operations,
|
|
6
|
+
* message execution with SSE streaming, and conversation history.
|
|
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.ThreadsResource = void 0;
|
|
13
|
+
class ThreadsResource {
|
|
14
|
+
client;
|
|
15
|
+
constructor(client) {
|
|
16
|
+
this.client = client;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create a new thread
|
|
20
|
+
*
|
|
21
|
+
* Project is determined automatically from the API key.
|
|
22
|
+
*/
|
|
23
|
+
async create(params) {
|
|
24
|
+
const response = await this.client.post(`/threads`, params);
|
|
25
|
+
return response.thread;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* List threads
|
|
29
|
+
*
|
|
30
|
+
* Project is determined automatically from the API key.
|
|
31
|
+
*/
|
|
32
|
+
async list(params = {}) {
|
|
33
|
+
const response = await this.client.get(`/threads`, {
|
|
34
|
+
limit: params.limit,
|
|
35
|
+
offset: params.offset,
|
|
36
|
+
environmentId: params.environmentId,
|
|
37
|
+
status: params.status,
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
data: response.data,
|
|
41
|
+
hasMore: response.has_more,
|
|
42
|
+
total: response.total_count,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get a thread by ID with full message history
|
|
47
|
+
*/
|
|
48
|
+
async get(threadId) {
|
|
49
|
+
const response = await this.client.get(`/threads/${threadId}`);
|
|
50
|
+
return response.thread;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Update a thread
|
|
54
|
+
*/
|
|
55
|
+
async update(threadId, params) {
|
|
56
|
+
const response = await this.client.patch(`/threads/${threadId}`, params);
|
|
57
|
+
return response.thread;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Delete a thread (soft delete)
|
|
61
|
+
*/
|
|
62
|
+
async delete(threadId) {
|
|
63
|
+
await this.client.delete(`/threads/${threadId}`);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get message history for a thread
|
|
67
|
+
*/
|
|
68
|
+
async getMessages(threadId) {
|
|
69
|
+
const response = await this.client.get(`/threads/${threadId}/messages`);
|
|
70
|
+
return {
|
|
71
|
+
data: response.data,
|
|
72
|
+
hasMore: response.has_more,
|
|
73
|
+
total: response.total_count,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Send a message to a thread and stream the response
|
|
78
|
+
*
|
|
79
|
+
* This method handles SSE streaming from the API and returns
|
|
80
|
+
* the complete result when finished.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const result = await client.threads.sendMessage(
|
|
85
|
+
* 'thread_456',
|
|
86
|
+
* {
|
|
87
|
+
* content: 'Create a REST API with Flask',
|
|
88
|
+
* onEvent: (event) => {
|
|
89
|
+
* if (event.type === 'response.item.completed') {
|
|
90
|
+
* console.log('Item:', event.item);
|
|
91
|
+
* }
|
|
92
|
+
* }
|
|
93
|
+
* }
|
|
94
|
+
* );
|
|
95
|
+
* console.log('Final response:', result.content);
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
async sendMessage(threadId, options) {
|
|
99
|
+
const { onEvent, timeout = 600000, ...params } = options;
|
|
100
|
+
// Make streaming request
|
|
101
|
+
const response = await this.client.request('POST', `/threads/${threadId}/messages`, {
|
|
102
|
+
body: params,
|
|
103
|
+
stream: true,
|
|
104
|
+
timeout,
|
|
105
|
+
});
|
|
106
|
+
const events = [];
|
|
107
|
+
let finalContent = '';
|
|
108
|
+
let runDetails;
|
|
109
|
+
// Parse SSE stream
|
|
110
|
+
const reader = response.body?.getReader();
|
|
111
|
+
if (!reader) {
|
|
112
|
+
throw new Error('No response body');
|
|
113
|
+
}
|
|
114
|
+
const decoder = new TextDecoder();
|
|
115
|
+
let buffer = '';
|
|
116
|
+
try {
|
|
117
|
+
while (true) {
|
|
118
|
+
const { done, value } = await reader.read();
|
|
119
|
+
if (done)
|
|
120
|
+
break;
|
|
121
|
+
buffer += decoder.decode(value, { stream: true });
|
|
122
|
+
const lines = buffer.split('\n');
|
|
123
|
+
buffer = lines.pop() || '';
|
|
124
|
+
for (const line of lines) {
|
|
125
|
+
if (line.startsWith('data: ')) {
|
|
126
|
+
try {
|
|
127
|
+
const data = JSON.parse(line.slice(6));
|
|
128
|
+
events.push(data);
|
|
129
|
+
// Call event callback if provided
|
|
130
|
+
if (onEvent) {
|
|
131
|
+
onEvent(data);
|
|
132
|
+
}
|
|
133
|
+
// Extract final content and run details
|
|
134
|
+
if (data.type === 'response.completed') {
|
|
135
|
+
finalContent = data.response?.content || '';
|
|
136
|
+
}
|
|
137
|
+
else if (data.type === 'stream.completed') {
|
|
138
|
+
runDetails = data.run;
|
|
139
|
+
}
|
|
140
|
+
else if (data.type === 'stream.error') {
|
|
141
|
+
throw new Error(data.message || data.error);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch (parseError) {
|
|
145
|
+
// Ignore parse errors for non-JSON lines
|
|
146
|
+
if (line.slice(6).trim()) {
|
|
147
|
+
console.warn('Failed to parse SSE data:', line);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
finally {
|
|
155
|
+
reader.releaseLock();
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
content: finalContent,
|
|
159
|
+
run: runDetails,
|
|
160
|
+
events,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Cancel an in-progress message execution
|
|
165
|
+
*/
|
|
166
|
+
async cancel(threadId) {
|
|
167
|
+
await this.client.post(`/threads/${threadId}/cancel`);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Resume a thread (useful after server restart)
|
|
171
|
+
*/
|
|
172
|
+
async resume(threadId) {
|
|
173
|
+
const response = await this.client.post(`/threads/${threadId}/resume`);
|
|
174
|
+
return response.thread;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.ThreadsResource = ThreadsResource;
|
|
178
|
+
//# sourceMappingURL=ThreadsResource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThreadsResource.js","sourceRoot":"","sources":["../../../src/cloud/resources/ThreadsResource.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AA6DH,MAAa,eAAe;IACG;IAA7B,YAA6B,MAAiB;QAAjB,WAAM,GAAN,MAAM,CAAW;IAAG,CAAC;IAElD;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,MAA0B;QACrC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACrC,UAAU,EACV,MAAM,CACP,CAAC;QACF,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,IAAI,CAAC,SAA4B,EAAE;QAKvC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAKnC,UAAU,EAAE;YACb,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,MAAM,EAAE,MAAM,CAAC,MAAM;SACtB,CAAC,CAAC;QACH,OAAO;YACL,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,OAAO,EAAE,QAAQ,CAAC,QAAQ;YAC1B,KAAK,EAAE,QAAQ,CAAC,WAAW;SAC5B,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,QAAgB;QACxB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CACpC,YAAY,QAAQ,EAAE,CACvB,CAAC;QACF,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CACV,QAAgB,EAChB,MAA0B;QAE1B,MAAM,QAAQ,GAAG,MAA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AAC,KAAK,CAAC,CAAC;4BAChE,CAAC;wBACH,CAAC;wBAAC,OAAO,UAAU,EAAE,CAAC;4BACpB,yCAAyC;4BACzC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;gCACzB,OAAO,CAAC,IAAI,CAAC,2BAA2B,EAAE,IAAI,CAAC,CAAC;4BAClD,CAAC;wBACH,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,CAAC;QAED,OAAO;YACL,OAAO,EAAE,YAAY;YACrB,GAAG,EAAE,UAAU;YACf,MAAM;SACP,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,QAAgB;QAC3B,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,QAAQ,SAAS,CAAC,CAAC;IACxD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,QAAgB;QAC3B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACrC,YAAY,QAAQ,SAAS,CAC9B,CAAC;QACF,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB,CAAC;CACF;AAtND,0CAsNC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloud Resource Managers
|
|
3
|
+
*
|
|
4
|
+
* Export all resource managers for use in CloudClient.
|
|
5
|
+
*/
|
|
6
|
+
export { ProjectsResource } from './ProjectsResource';
|
|
7
|
+
export { EnvironmentsResource } from './EnvironmentsResource';
|
|
8
|
+
export type { ListEnvironmentsParams } from './EnvironmentsResource';
|
|
9
|
+
export { ThreadsResource } from './ThreadsResource';
|
|
10
|
+
export type { StreamEventCallback, SendMessageOptions, SendMessageResult } from './ThreadsResource';
|
|
11
|
+
export { RunsResource } from './RunsResource';
|
|
12
|
+
export { AgentsResource } from './AgentsResource';
|
|
13
|
+
export { BudgetResource, BillingResource } from './BudgetResource';
|
|
14
|
+
export { SchedulesResource } from './SchedulesResource';
|
|
15
|
+
export { GitResource } from './GitResource';
|
|
16
|
+
export { FilesResource } from './FilesResource';
|
|
17
|
+
export type { EnvironmentFile, ListFilesResult, UploadFileParams, UploadFileResult, MoveFileParams, MoveFileResult, DeleteFileResult, CreateDirectoryResult, } from './FilesResource';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Cloud Resource Managers
|
|
4
|
+
*
|
|
5
|
+
* Export all resource managers for use in CloudClient.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.FilesResource = exports.GitResource = exports.SchedulesResource = exports.BillingResource = exports.BudgetResource = exports.AgentsResource = exports.RunsResource = exports.ThreadsResource = exports.EnvironmentsResource = exports.ProjectsResource = void 0;
|
|
9
|
+
var ProjectsResource_1 = require("./ProjectsResource");
|
|
10
|
+
Object.defineProperty(exports, "ProjectsResource", { enumerable: true, get: function () { return ProjectsResource_1.ProjectsResource; } });
|
|
11
|
+
var EnvironmentsResource_1 = require("./EnvironmentsResource");
|
|
12
|
+
Object.defineProperty(exports, "EnvironmentsResource", { enumerable: true, get: function () { return EnvironmentsResource_1.EnvironmentsResource; } });
|
|
13
|
+
var ThreadsResource_1 = require("./ThreadsResource");
|
|
14
|
+
Object.defineProperty(exports, "ThreadsResource", { enumerable: true, get: function () { return ThreadsResource_1.ThreadsResource; } });
|
|
15
|
+
var RunsResource_1 = require("./RunsResource");
|
|
16
|
+
Object.defineProperty(exports, "RunsResource", { enumerable: true, get: function () { return RunsResource_1.RunsResource; } });
|
|
17
|
+
var AgentsResource_1 = require("./AgentsResource");
|
|
18
|
+
Object.defineProperty(exports, "AgentsResource", { enumerable: true, get: function () { return AgentsResource_1.AgentsResource; } });
|
|
19
|
+
var BudgetResource_1 = require("./BudgetResource");
|
|
20
|
+
Object.defineProperty(exports, "BudgetResource", { enumerable: true, get: function () { return BudgetResource_1.BudgetResource; } });
|
|
21
|
+
Object.defineProperty(exports, "BillingResource", { enumerable: true, get: function () { return BudgetResource_1.BillingResource; } });
|
|
22
|
+
var SchedulesResource_1 = require("./SchedulesResource");
|
|
23
|
+
Object.defineProperty(exports, "SchedulesResource", { enumerable: true, get: function () { return SchedulesResource_1.SchedulesResource; } });
|
|
24
|
+
var GitResource_1 = require("./GitResource");
|
|
25
|
+
Object.defineProperty(exports, "GitResource", { enumerable: true, get: function () { return GitResource_1.GitResource; } });
|
|
26
|
+
var FilesResource_1 = require("./FilesResource");
|
|
27
|
+
Object.defineProperty(exports, "FilesResource", { enumerable: true, get: function () { return FilesResource_1.FilesResource; } });
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cloud/resources/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAE7B,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AAExB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,mDAAmE;AAA1D,gHAAA,cAAc,OAAA;AAAE,iHAAA,eAAe,OAAA;AACxC,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAC1B,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA"}
|