@ctyun/desktop-agent-sdk 0.0.1

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 ADDED
@@ -0,0 +1,420 @@
1
+ # Desktop Agent SDK
2
+
3
+ 用于操作天翼云电脑的一套SDK,支持鼠标控制、键盘输入、屏幕截图等操作。
4
+
5
+ ## 项目简介
6
+
7
+ `@ctyun/desktop-agent-sdk` 是天翼云电脑远程操作 SDK,第三方开发者可以通过该 SDK 以编程方式控制远程桌面。支持以下功能:
8
+
9
+ - 鼠标移动、点击、拖拽和滚动
10
+ - 键盘按键和文本输入
11
+ - 屏幕截图
12
+ - 获取鼠标位置
13
+
14
+ ## 安装方法
15
+
16
+ ### npm 安装
17
+
18
+ ```bash
19
+ npm install @ctyun/desktop-agent-sdk
20
+ ```
21
+
22
+ ### yarn 安装
23
+
24
+ ```bash
25
+ yarn add @ctyun/desktop-agent-sdk
26
+ ```
27
+
28
+ ### pnpm 安装
29
+
30
+ ```bash
31
+ pnpm add @ctyun/desktop-agent-sdk
32
+ ```
33
+
34
+ ## 基本使用方法
35
+
36
+ ### 3.1 创建 Client 实例
37
+
38
+ 首先导入并创建 Client 实例。创建实例时需要提供以下参数:
39
+
40
+ - `apiKey` (必需): 控制台上的AccessKey ID
41
+ - `apiSecret` (必需): 控制台上的AccessKey Secret
42
+ - `desktopCode` (必需): 桌面编码
43
+ - `serviceURL` (可选): 服务地址,默认为 `https://desk.ctyun.cn:8816`
44
+
45
+ ```javascript
46
+ import Client from '@ctyun/desktop-agent-sdk';
47
+
48
+ const client = new Client({
49
+ apiKey: 'your-api-key',
50
+ apiSecret: 'your-api-secret',
51
+ desktopCode: 'your-desktop-code',
52
+ serviceURL: 'https://desk.ctyun.cn:8816' // 可选,使用默认值
53
+ });
54
+ ```
55
+
56
+ ### 3.2 创建会话
57
+
58
+ 使用 `createSession()` 方法创建会话,会话创建成功后将返回会话对象,包含 sessionId 和操作方法。
59
+
60
+ ```javascript
61
+ const session = await client.createSession();
62
+ console.log('会话创建成功,sessionId:', session.sessionId);
63
+ ```
64
+
65
+ ### 3.3 使用 computer 方法
66
+
67
+ 创建会话后,可以通过 `session.computer` 对象调用各种计算机控制方法。
68
+
69
+ #### 移动鼠标
70
+
71
+ ```javascript
72
+ // 将鼠标移动到指定坐标
73
+ await session.computer.move_mouse(500, 300);
74
+ ```
75
+
76
+ #### 点击鼠标
77
+
78
+ ```javascript
79
+ // 在指定坐标点击鼠标(默认左键、按下并释放)
80
+ await session.computer.click_mouse(500, 300);
81
+
82
+ // 点击右键
83
+ await session.computer.click_mouse(500, 300, 'right');
84
+
85
+ // 仅按下鼠标(不释放)
86
+ await session.computer.click_mouse(500, 300, 'left', 'down');
87
+
88
+ // 仅释放鼠标
89
+ await session.computer.click_mouse(500, 300, 'left', 'up');
90
+ ```
91
+
92
+ #### 按下和释放鼠标
93
+
94
+ ```javascript
95
+ // 按下鼠标
96
+ await session.computer.press_mouse(500, 300, 'left');
97
+
98
+ // 释放鼠标
99
+ await session.computer.release_mouse(500, 300, 'left');
100
+ ```
101
+
102
+ #### 拖拽鼠标
103
+
104
+ ```javascript
105
+ // 从起始坐标拖拽到目标坐标
106
+ await session.computer.drag_mouse(500, 300, 800, 500);
107
+ ```
108
+
109
+ #### 滚动
110
+
111
+ ```javascript
112
+ // 在指定位置滚动(Direction: 'up' 或 'down')
113
+ await session.computer.scroll(500, 300, 'down', 3);
114
+ ```
115
+
116
+ #### 按下键盘按键
117
+
118
+ ```javascript
119
+ // 按下键盘按键(如 Enter)
120
+ await session.computer.press_key('Enter');
121
+ ```
122
+
123
+ #### 输入文本
124
+
125
+ ```javascript
126
+ // 输入文本
127
+ await session.computer.type_text('Hello World');
128
+ ```
129
+
130
+ #### 屏幕截图
131
+
132
+ ```javascript
133
+ // 截取屏幕
134
+ await session.computer.screen_shot();
135
+ ```
136
+
137
+ #### 获取鼠标位置
138
+
139
+ ```javascript
140
+ // 获取当前鼠标位置
141
+ await session.computer.get_cursor_position();
142
+ ```
143
+
144
+ ### 3.4 查询任务状态
145
+
146
+ 对于异步执行的操作,可以使用 `query_job()` 方法查询任务执行状态和结果。
147
+
148
+ ```javascript
149
+ // 假设某个操作返回了 jobId
150
+ const jobId = 'your-job-id';
151
+
152
+ // 查询任务状态
153
+ const result = await session.query_job(jobId);
154
+ console.log('任务状态:', result);
155
+ ```
156
+
157
+ ### 3.5 关闭会话
158
+
159
+ 使用完成后,应该关闭会话以释放资源。
160
+
161
+ ```javascript
162
+ await session.close();
163
+ console.log('会话已关闭');
164
+ ```
165
+
166
+ ## 完整示例
167
+
168
+ ```javascript
169
+ import Client from '@ctyun/desktop-agent-sdk';
170
+
171
+ async function main() {
172
+ // 创建 Client 实例
173
+ const client = new Client({
174
+ apiKey: 'your-api-key',
175
+ apiSecret: 'your-api-secret',
176
+ desktopCode: 'your-desktop-code'
177
+ });
178
+
179
+ let session=null;
180
+ try {
181
+ // 创建会话
182
+ session = await client.createSession();
183
+ console.log('会话创建成功:', session.sessionId);
184
+
185
+ // 移动鼠标并点击
186
+ await session.computer.move_mouse(500, 300);
187
+ await session.computer.click_mouse(500, 300);
188
+
189
+ // 输入文本
190
+ await session.computer.type_text('Hello from Desktop Agent SDK!');
191
+
192
+ // 截图
193
+ await session.computer.screen_shot();
194
+ } catch (error) {
195
+ console.error('操作失败:', error);
196
+ } finally {
197
+ // 关闭会话
198
+ await session.close();
199
+ }
200
+ }
201
+
202
+ main();
203
+ ```
204
+
205
+ ## 4、API 参考
206
+
207
+ ### Client 类
208
+
209
+ #### 构造函数
210
+
211
+ ```typescript
212
+ new Client(options: ClientOptions): Client
213
+ ```
214
+
215
+ **ClientOptions 参数说明:**
216
+
217
+ | 参数名 | 类型 | 必需 | 说明 |
218
+ |--------|------|------|------|
219
+ | apiKey | string | 是 | 控制台上的AccessKey ID [打开控制台](https://desk.ctyun.cn/cloudB/) |
220
+ | apiSecret | string | 是 | 控制台上的AccessKey Secret |
221
+ | desktopCode | string | 是 | 桌面编码,控制台可查看 |
222
+ | serviceURL | string | 否 | 服务地址,默认 `https://desk.ctyun.cn:8816` |
223
+
224
+ #### 方法
225
+
226
+ ##### createSession()
227
+
228
+ 创建会话并返回会话对象。
229
+
230
+ ```typescript
231
+ async createSession(): Promise<Session>
232
+ ```
233
+
234
+ **返回值:**
235
+
236
+ | 属性名 | 类型 | 说明 |
237
+ |--------|------|------|
238
+ | sessionId | string | 会话唯一标识 |
239
+ | computer | ComputerAPI | 计算机控制方法集合 |
240
+ | query_job | Function | 查询任务状态方法 |
241
+ | close | Function | 关闭会话方法 |
242
+
243
+ ### Session 对象
244
+
245
+ - #### computer 对象
246
+
247
+ #### 返回值说明
248
+ 对computer类下面的所有方法的调用都是**异步调用**,返回值遵循相同的返回格式:
249
+ ``` json
250
+ {
251
+ "code": 0,
252
+ "data": {
253
+ "requestId": "",
254
+ "sessionId": "",
255
+ "desktopCode": "",
256
+ "jobId": "",
257
+ "jobStatus": 1,
258
+ "jobRollInterval": 100,
259
+ "jobRollTimes": 16
260
+ }
261
+ }
262
+ ```
263
+ | 参数名 | 类型 | 说明 |
264
+ |--------|------|------|
265
+ | requestId | string | 本次请求的ID |
266
+ | sessionId | number | 会话ID,同`createSession`返回值相同 |
267
+ | desktopCode | number | 桌面编码 |
268
+ | jobId | number | 本次请求的任务ID,用于后续轮询查看结果 |
269
+ | jobStatus | number | 任务状态:<br/>-1:未响应<br/> 1:接收成功<br/>2:接收失败<br/>3:执行成功<br/>4:执行失败|
270
+ | jobRollIntervalMs | number | 建议的轮询间隔,单位:ms |
271
+ | jobRollTimes | number | 建议的轮询次数 |
272
+
273
+ 你可以通过这里返回的`jobId`轮询调用query_job方法,拿到对应操作的执行结果。
274
+
275
+ ##### move_mouse(x, y)
276
+
277
+ 移动鼠标到指定坐标。
278
+
279
+ | 参数名 | 类型 | 说明 |
280
+ |--------|------|------|
281
+ | x | number | 目标 X 坐标 |
282
+ | y | number | 目标 Y 坐标 |
283
+
284
+ ##### click_mouse(x, y, clickMode?, pressMode?)
285
+
286
+ 在指定位置点击鼠标。
287
+
288
+ | 参数名 | 类型 | 必需 | 说明 |
289
+ |--------|------|------|------|
290
+ | x | number | 是 | X 坐标 |
291
+ | y | number | 是 | Y 坐标 |
292
+ | clickMode | string | 否 | 点击模式:`'left'`(默认)、`'right'`、`'middle'` |
293
+ | pressMode | string | 否 | 按下模式:`'down'`、`'up'`,不传则按下并释放 |
294
+
295
+ ##### press_mouse(x, y, pressMode?)
296
+
297
+ 按下鼠标。
298
+
299
+ | 参数名 | 类型 | 必需 | 说明 |
300
+ |--------|------|------|------|
301
+ | x | number | 是 | X 坐标 |
302
+ | y | number | 是 | Y 坐标 |
303
+ | pressMode | string | 否 | 按键模式:`'left'`(默认)、`'right'`、`'middle'` |
304
+
305
+ ##### release_mouse(x, y, releaseMode?)
306
+
307
+ 释放鼠标。
308
+
309
+ | 参数名 | 类型 | 必需 | 说明 |
310
+ |--------|------|------|------|
311
+ | x | number | 是 | X 坐标 |
312
+ | y | number | 是 | Y 坐标 |
313
+ | releaseMode | string | 否 | 释放模式:`'left'`(默认)、`'right'`、`'middle'` |
314
+
315
+ ##### drag_mouse(startX, startY, endX, endY)
316
+
317
+ 拖拽鼠标。
318
+
319
+ | 参数名 | 类型 | 说明 |
320
+ |--------|------|------|
321
+ | startX | number | 起始 X 坐标 |
322
+ | startY | number | 起始 Y 坐标 |
323
+ | endX | number | 目标 X 坐标 |
324
+ | endY | number | 目标 Y 坐标 |
325
+
326
+ ##### scroll(startX, startY, direction, amount)
327
+
328
+ 滚动页面。
329
+
330
+ | 参数名 | 类型 | 说明 |
331
+ |--------|------|------|
332
+ | startX | number | 滚动位置 X 坐标 |
333
+ | startY | number | 滚动位置 Y 坐标 |
334
+ | direction | string | 滚动方向:`'up'` 或 `'down'` |
335
+ | amount | number | 滚动量,单位:px |
336
+
337
+ ##### press_key(key)
338
+
339
+ 按下键盘按键。
340
+
341
+ | 参数名 | 类型 | 说明 |
342
+ |--------|------|------|
343
+ | key | string | 按键名称,如 `'Enter'`、`'Escape'` 等 |
344
+
345
+ ##### type_text(text)
346
+
347
+ 输入文本。
348
+
349
+ | 参数名 | 类型 | 说明 |
350
+ |--------|------|------|
351
+ | text | string | 要输入的文本内容 |
352
+
353
+ ##### screen_shot()
354
+
355
+ 截取屏幕。
356
+
357
+ **返回值:**
358
+ 通过query_job轮询查询结果
359
+
360
+ ##### get_cursor_position()
361
+
362
+ 获取当前鼠标位置。
363
+
364
+ **返回值:**
365
+ 通过query_job轮询查询结果
366
+
367
+ - #### query_job(jobId)
368
+
369
+ 查询异步任务执行结果。
370
+
371
+ | 参数名 | 类型 | 说明 |
372
+ |--------|------|------|
373
+ | jobId | string | 任务 ID |
374
+
375
+ **返回值:**
376
+ ``` json
377
+ {
378
+ "code": 0,
379
+ "data": {
380
+ "requestId": "",
381
+ "desktopCode": "",
382
+ "sessionId": "",
383
+ "jobId": "",
384
+ "jobStatus": 1,
385
+ "resp": ""
386
+ }
387
+ }
388
+ ```
389
+ | 参数名 | 类型 | 说明 |
390
+ |--------|------|------|
391
+ | requestId | string | 本次请求的ID |
392
+ | sessionId | number | 会话ID,同`createSession`返回值相同 |
393
+ | desktopCode | number | 桌面编码 |
394
+ | jobId | number | 本次查询的任务ID |
395
+ | jobStatus | number | 任务状态:<br/>-1:未响应<br/> 1:接收成功<br/>2:接收失败<br/>3:执行成功<br/>4:执行失败|
396
+ | resp | string | 操作的执行结果返回值 |
397
+
398
+ **示例:** 执行屏幕截图
399
+ ``` javascript
400
+ ...创建client和session
401
+ const res = await session.computer.screen_shot();
402
+ const {jobId,jobRollIntervalMs,jobRollTimes}=res.data
403
+
404
+ let n_roll_times=0
405
+ const do_query_job=async ()=>{
406
+ if(n_roll_times>jobRollTimes) return
407
+ const result=await session.query_job(jobId)
408
+ const {jobStatus,resp}=result.data
409
+ if(resp) console.log("操作结果是:"+resp)
410
+ else setTimeout(()=>do_query_job(),jobRollIntervalMs)
411
+ }
412
+ setTimeout(()=>do_query_job(),jobRollIntervalMs)
413
+
414
+ ```
415
+
416
+ - #### close()
417
+
418
+ 关闭当前会话。
419
+
420
+ **返回值:** 关闭结果
@@ -0,0 +1,2 @@
1
+ /*! @ctyun/desktop-agent-sdk v0.0.1 | (c) 2026-02-05 zhangjiliang | https://desk.ctyun.cn/html/download/ */
2
+ "use strict";var e=require("axios"),s=require("node:crypto");const t=e.create({baseURL:"/api/openApi"});var o={createSeesion:function(e,s){return t.post("/cdserv/aiUse/createSeesion",e,{...s})},sendMessage:function(e,s){return t.post("/cdserv/aiUse/sendMessage",e,{...s})},queryJob:function(e,s){return t.post("/cdserv/aiUse/queryJob",e,{...s})},deleteSession:function(e,s){return t.post("/cdserv/aiUse/deleteSession",e,{...s})}};const r=e=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",o=s.randomBytes(e);let r="";for(let e=0;e<o.length;e++)r+=t[o[e]%62];return r.slice(0,e)},i=e=>{const{path:t,body:o,apiKey:i,apiSecret:n}=e;let a={};const c=t.indexOf("?");-1!==c&&(a=(e=>{if(!e)return{};let s={},t=e.split("&");for(let e=0;e<t.length;e++){let o=t[e].split("=");s[o[0]]=o[1]}return s})(t.slice(c+1)));const d={"x-ctg-ecpc-ak":i,"x-ctg-algorithm":"SHA256","x-ctg-timestamp":(new Date).getTime(),"x-ctg-nonStr":r(8)};o&&(d["x-ctg-reqJson"]=(e=>{const t=s.createHash("md5");return t.update(e),t.digest("hex")})(JSON.stringify(o)));const p=Object.assign({},a,d),u=[],h=Object.keys(p);h.sort(),h.forEach(e=>{u.push(`${e}=${p[e]}`)});const l=u.join("&")+n;return d.sign=(e=>{const t=s.createHash("sha256");return t.update(e),t.digest("hex")})(l),d},n=(e,t)=>{const o=s.createCipheriv("aes-256-cbc",t,"0000000000000000");let r=o.update(e,"utf8","base64");return r+=o.final("base64"),r};var a=Object.freeze({__proto__:null,click_mouse:(e,s,t="left",o="down")=>({action:"ClickMouse",params:{PositionX:e,PositionY:s,Button:t,Press:"down"==o,Release:"up"==o}}),drag_mouse:(e,s,t,o)=>({action:"DragMouse",params:{SourceX:e,SourceY:s,TargetX:t,TargetY:o}}),get_cursor_position:()=>({action:"GetCursorPosition"}),move_mouse:(e,s)=>({action:"MoveMouse",params:{PositionX:e,PositionY:s}}),press_key:e=>({action:"PressKey",params:{Key:e}}),press_mouse:(e,s,t="left")=>({action:"PressMouse",params:{PositionX:e,PositionY:s,Button:t}}),release_mouse:(e,s,t="left")=>({action:"ReleaseMouse",params:{PositionX:e,PositionY:s,Button:t}}),screen_shot:()=>({action:"TakeScreenshot"}),scroll:(e,s,t,o)=>({action:"Scroll",params:{PositionX:e,PositionY:s,Direction:t,Amount:o}}),type_text:e=>({action:"TypeText",params:{Text:e}})});const c=(e,s)=>{const{apiKey:t,apiSecret:o,path:r}=s;return{headers:i({path:r||"",body:e,apiKey:t,apiSecret:o}),body:e}};module.exports=class{constructor(e={}){this.options=Object.assign({serviceURL:"https://desk.ctyun.cn:8816"},e);const{apiKey:s,apiSecret:t,desktopCode:o,serviceURL:r}=this.options;if(!s||!t)throw new Error("apiKey或apiSecret不能为空");if(!r)throw new Error("serviceURL不能为空");if(!o)throw new Error("desktopCode不能为空")}async createSession(){const{apiKey:e,apiSecret:s,desktopCode:t,serviceURL:i}=this.options,d={requestId:r(32),desktopCode:t};c(d,{apiKey:e,apiSecret:s});const p=this.sessionId="test-session-id",u=Object.keys(a).reduce((d,u)=>(d[u]=async(...d)=>{if(!this.sessionId)throw new Error("会话已关闭或未创建");const h=a[u](...d),l=r(32),y={requestId:l,desktopCode:t,sessionId:p,message:n(JSON.stringify(h),l)},{headers:g,body:m}=c(y,{apiKey:e,apiSecret:s});return(await o.sendMessage(m,{headers:g,baseURL:i})).data},d),{});return{sessionId:p,query_job:async n=>{if(!this.sessionId)throw new Error("会话已关闭或未创建");const a={requestId:r(32),desktopCode:t,sessionId:p,jobId:n},{headers:d,body:u}=c(a,{apiKey:e,apiSecret:s});return(await o.queryJob(u,{headers:d,baseURL:i})).data},close:async()=>{if(!this.sessionId)return;const n={requestId:r(32),desktopCode:t,sessionId:p},{headers:a,body:d}=c(n,{apiKey:e,apiSecret:s}),u=await o.deleteSession(d,{headers:a,baseURL:i});return this.sessionId=null,u.data},computer:u}}};
@@ -0,0 +1,2 @@
1
+ /*! @ctyun/desktop-agent-sdk v0.0.1 | (c) 2026-02-05 zhangjiliang | https://desk.ctyun.cn/html/download/ */
2
+ import e from"axios";import s from"node:crypto";const t=e.create({baseURL:"/api/openApi"});var o={createSeesion:function(e,s){return t.post("/cdserv/aiUse/createSeesion",e,{...s})},sendMessage:function(e,s){return t.post("/cdserv/aiUse/sendMessage",e,{...s})},queryJob:function(e,s){return t.post("/cdserv/aiUse/queryJob",e,{...s})},deleteSession:function(e,s){return t.post("/cdserv/aiUse/deleteSession",e,{...s})}};const r=e=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",o=s.randomBytes(e);let r="";for(let e=0;e<o.length;e++)r+=t[o[e]%62];return r.slice(0,e)},i=e=>{const{path:t,body:o,apiKey:i,apiSecret:n}=e;let a={};const c=t.indexOf("?");-1!==c&&(a=(e=>{if(!e)return{};let s={},t=e.split("&");for(let e=0;e<t.length;e++){let o=t[e].split("=");s[o[0]]=o[1]}return s})(t.slice(c+1)));const d={"x-ctg-ecpc-ak":i,"x-ctg-algorithm":"SHA256","x-ctg-timestamp":(new Date).getTime(),"x-ctg-nonStr":r(8)};o&&(d["x-ctg-reqJson"]=(e=>{const t=s.createHash("md5");return t.update(e),t.digest("hex")})(JSON.stringify(o)));const p=Object.assign({},a,d),u=[],h=Object.keys(p);h.sort(),h.forEach(e=>{u.push(`${e}=${p[e]}`)});const l=u.join("&")+n;return d.sign=(e=>{const t=s.createHash("sha256");return t.update(e),t.digest("hex")})(l),d},n=(e,t)=>{const o=s.createCipheriv("aes-256-cbc",t,"0000000000000000");let r=o.update(e,"utf8","base64");return r+=o.final("base64"),r};var a=Object.freeze({__proto__:null,click_mouse:(e,s,t="left",o="down")=>({action:"ClickMouse",params:{PositionX:e,PositionY:s,Button:t,Press:"down"==o,Release:"up"==o}}),drag_mouse:(e,s,t,o)=>({action:"DragMouse",params:{SourceX:e,SourceY:s,TargetX:t,TargetY:o}}),get_cursor_position:()=>({action:"GetCursorPosition"}),move_mouse:(e,s)=>({action:"MoveMouse",params:{PositionX:e,PositionY:s}}),press_key:e=>({action:"PressKey",params:{Key:e}}),press_mouse:(e,s,t="left")=>({action:"PressMouse",params:{PositionX:e,PositionY:s,Button:t}}),release_mouse:(e,s,t="left")=>({action:"ReleaseMouse",params:{PositionX:e,PositionY:s,Button:t}}),screen_shot:()=>({action:"TakeScreenshot"}),scroll:(e,s,t,o)=>({action:"Scroll",params:{PositionX:e,PositionY:s,Direction:t,Amount:o}}),type_text:e=>({action:"TypeText",params:{Text:e}})});const c=(e,s)=>{const{apiKey:t,apiSecret:o,path:r}=s;return{headers:i({path:r||"",body:e,apiKey:t,apiSecret:o}),body:e}};class d{constructor(e={}){this.options=Object.assign({serviceURL:"https://desk.ctyun.cn:8816"},e);const{apiKey:s,apiSecret:t,desktopCode:o,serviceURL:r}=this.options;if(!s||!t)throw new Error("apiKey或apiSecret不能为空");if(!r)throw new Error("serviceURL不能为空");if(!o)throw new Error("desktopCode不能为空")}async createSession(){const{apiKey:e,apiSecret:s,desktopCode:t,serviceURL:i}=this.options,d={requestId:r(32),desktopCode:t};c(d,{apiKey:e,apiSecret:s});const p=this.sessionId="test-session-id",u=Object.keys(a).reduce((d,u)=>(d[u]=async(...d)=>{if(!this.sessionId)throw new Error("会话已关闭或未创建");const h=a[u](...d),l=r(32),y={requestId:l,desktopCode:t,sessionId:p,message:n(JSON.stringify(h),l)},{headers:m,body:f}=c(y,{apiKey:e,apiSecret:s});return(await o.sendMessage(f,{headers:m,baseURL:i})).data},d),{});return{sessionId:p,query_job:async n=>{if(!this.sessionId)throw new Error("会话已关闭或未创建");const a={requestId:r(32),desktopCode:t,sessionId:p,jobId:n},{headers:d,body:u}=c(a,{apiKey:e,apiSecret:s});return(await o.queryJob(u,{headers:d,baseURL:i})).data},close:async()=>{if(!this.sessionId)return;const n={requestId:r(32),desktopCode:t,sessionId:p},{headers:a,body:d}=c(n,{apiKey:e,apiSecret:s}),u=await o.deleteSession(d,{headers:a,baseURL:i});return this.sessionId=null,u.data},computer:u}}}export{d as default};
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@ctyun/desktop-agent-sdk",
3
+ "version": "0.0.1",
4
+ "description": "the agent web sdk to interactive with your computer",
5
+ "main": "dist/index.cjs.js",
6
+ "module": "dist/index.esm.js",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.esm.js",
10
+ "require": "./dist/index.cjs.js",
11
+ "default": "./dist/index.cjs.js"
12
+ }
13
+ },
14
+ "author": "zhangjiliang",
15
+ "homepage": "https://desk.ctyun.cn/html/download/",
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "scripts": {
20
+ "build": "rollup -c rollup.config.mjs",
21
+ "prepublishOnly": "npm run build"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "devDependencies": {
27
+ "@rollup/plugin-commonjs": "^29.0.0",
28
+ "@rollup/plugin-node-resolve": "^16.0.3",
29
+ "@rollup/plugin-terser": "^0.4.4",
30
+ "rollup": "^4.55.1",
31
+ "rollup-plugin-delete": "^3.0.2",
32
+ "rollup-plugin-license": "^3.6.0"
33
+ },
34
+ "dependencies": {
35
+ "axios": "^1.13.4"
36
+ }
37
+ }