@yvhitxcel/opencode-remote 0.15.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 (102) hide show
  1. package/README.md +82 -0
  2. package/bin/opencode-remote.js +70 -0
  3. package/bin/opencode-weixin.js +10 -0
  4. package/dist/AGENTS.md +20 -0
  5. package/dist/MEMORY.md +21 -0
  6. package/dist/bot-runner.js +180 -0
  7. package/dist/cli.js +256 -0
  8. package/dist/core/approval.js +95 -0
  9. package/dist/core/auth.js +119 -0
  10. package/dist/core/config.js +61 -0
  11. package/dist/core/notifications.js +134 -0
  12. package/dist/core/qiniu.js +267 -0
  13. package/dist/core/registry.js +86 -0
  14. package/dist/core/router.js +344 -0
  15. package/dist/core/session.js +403 -0
  16. package/dist/core/setup.js +418 -0
  17. package/dist/core/types.js +16 -0
  18. package/dist/feishu/adapter.js +72 -0
  19. package/dist/feishu/bot.js +168 -0
  20. package/dist/feishu/commands.js +601 -0
  21. package/dist/feishu/handler.js +380 -0
  22. package/dist/index.js +60 -0
  23. package/dist/opencode/client.js +823 -0
  24. package/dist/package-lock.json +762 -0
  25. package/dist/patch_spawn.js +28 -0
  26. package/dist/plugins/agents/acp/acp-adapter.js +42 -0
  27. package/dist/plugins/agents/claude-code/index.js +69 -0
  28. package/dist/plugins/agents/codex/index.js +44 -0
  29. package/dist/plugins/agents/copilot/index.js +44 -0
  30. package/dist/plugins/agents/opencode/index.js +66 -0
  31. package/dist/telegram/bot.js +288 -0
  32. package/dist/utils/message-split.js +38 -0
  33. package/dist/web/code-viewer.js +266 -0
  34. package/dist/weixin/adapter.js +135 -0
  35. package/dist/weixin/api.js +179 -0
  36. package/dist/weixin/bot.js +183 -0
  37. package/dist/weixin/commands.js +758 -0
  38. package/dist/weixin/handler.js +577 -0
  39. package/dist/weixin/node_modules/encodeurl/LICENSE +22 -0
  40. package/dist/weixin/node_modules/encodeurl/README.md +109 -0
  41. package/dist/weixin/node_modules/encodeurl/index.js +60 -0
  42. package/dist/weixin/node_modules/encodeurl/package.json +40 -0
  43. package/dist/weixin/node_modules/qiniu/.claude/settings.local.json +7 -0
  44. package/dist/weixin/node_modules/qiniu/.github/workflows/ci-test.yml +36 -0
  45. package/dist/weixin/node_modules/qiniu/.github/workflows/npm-publish.yml +20 -0
  46. package/dist/weixin/node_modules/qiniu/.github/workflows/version-check.yml +19 -0
  47. package/dist/weixin/node_modules/qiniu/.idea/MarsCodeWorkspaceAppSettings.xml +7 -0
  48. package/dist/weixin/node_modules/qiniu/.idea/codeStyles/Project.xml +44 -0
  49. package/dist/weixin/node_modules/qiniu/.idea/codeStyles/codeStyleConfig.xml +5 -0
  50. package/dist/weixin/node_modules/qiniu/.idea/git_toolbox_blame.xml +6 -0
  51. package/dist/weixin/node_modules/qiniu/.idea/inspectionProfiles/Project_Default.xml +6 -0
  52. package/dist/weixin/node_modules/qiniu/.idea/jsLibraryMappings.xml +6 -0
  53. package/dist/weixin/node_modules/qiniu/.idea/modules.xml +8 -0
  54. package/dist/weixin/node_modules/qiniu/.idea/nodejs-sdk.iml +12 -0
  55. package/dist/weixin/node_modules/qiniu/.idea/vcs.xml +6 -0
  56. package/dist/weixin/node_modules/qiniu/CHANGELOG.md +292 -0
  57. package/dist/weixin/node_modules/qiniu/README.md +56 -0
  58. package/dist/weixin/node_modules/qiniu/StorageResponseInterface.d.ts +239 -0
  59. package/dist/weixin/node_modules/qiniu/codecov.yml +28 -0
  60. package/dist/weixin/node_modules/qiniu/index.d.ts +1995 -0
  61. package/dist/weixin/node_modules/qiniu/index.js +32 -0
  62. package/dist/weixin/node_modules/qiniu/node_modules/encodeurl/HISTORY.md +14 -0
  63. package/dist/weixin/node_modules/qiniu/node_modules/encodeurl/LICENSE +22 -0
  64. package/dist/weixin/node_modules/qiniu/node_modules/encodeurl/README.md +128 -0
  65. package/dist/weixin/node_modules/qiniu/node_modules/encodeurl/index.js +60 -0
  66. package/dist/weixin/node_modules/qiniu/node_modules/encodeurl/package.json +40 -0
  67. package/dist/weixin/node_modules/qiniu/package.json +80 -0
  68. package/dist/weixin/node_modules/qiniu/qiniu/auth/digest.js +13 -0
  69. package/dist/weixin/node_modules/qiniu/qiniu/cdn.js +149 -0
  70. package/dist/weixin/node_modules/qiniu/qiniu/conf.js +254 -0
  71. package/dist/weixin/node_modules/qiniu/qiniu/fop.js +112 -0
  72. package/dist/weixin/node_modules/qiniu/qiniu/httpc/client.js +253 -0
  73. package/dist/weixin/node_modules/qiniu/qiniu/httpc/endpoint.js +66 -0
  74. package/dist/weixin/node_modules/qiniu/qiniu/httpc/endpointsProvider.js +27 -0
  75. package/dist/weixin/node_modules/qiniu/qiniu/httpc/endpointsRetryPolicy.js +76 -0
  76. package/dist/weixin/node_modules/qiniu/qiniu/httpc/middleware/base.js +31 -0
  77. package/dist/weixin/node_modules/qiniu/qiniu/httpc/middleware/index.js +9 -0
  78. package/dist/weixin/node_modules/qiniu/qiniu/httpc/middleware/qiniuAuth.js +53 -0
  79. package/dist/weixin/node_modules/qiniu/qiniu/httpc/middleware/retryDomains.js +101 -0
  80. package/dist/weixin/node_modules/qiniu/qiniu/httpc/middleware/ua.js +36 -0
  81. package/dist/weixin/node_modules/qiniu/qiniu/httpc/region.js +349 -0
  82. package/dist/weixin/node_modules/qiniu/qiniu/httpc/regionsProvider.js +788 -0
  83. package/dist/weixin/node_modules/qiniu/qiniu/httpc/regionsRetryPolicy.js +242 -0
  84. package/dist/weixin/node_modules/qiniu/qiniu/httpc/responseWrapper.js +40 -0
  85. package/dist/weixin/node_modules/qiniu/qiniu/retry/index.js +4 -0
  86. package/dist/weixin/node_modules/qiniu/qiniu/retry/retrier.js +99 -0
  87. package/dist/weixin/node_modules/qiniu/qiniu/retry/retryPolicy.js +55 -0
  88. package/dist/weixin/node_modules/qiniu/qiniu/rpc.js +237 -0
  89. package/dist/weixin/node_modules/qiniu/qiniu/rtc/app.js +123 -0
  90. package/dist/weixin/node_modules/qiniu/qiniu/rtc/credentials.js +57 -0
  91. package/dist/weixin/node_modules/qiniu/qiniu/rtc/room.js +118 -0
  92. package/dist/weixin/node_modules/qiniu/qiniu/rtc/util.js +16 -0
  93. package/dist/weixin/node_modules/qiniu/qiniu/sms/message.js +58 -0
  94. package/dist/weixin/node_modules/qiniu/qiniu/storage/form.js +442 -0
  95. package/dist/weixin/node_modules/qiniu/qiniu/storage/internal.js +214 -0
  96. package/dist/weixin/node_modules/qiniu/qiniu/storage/resume.js +1272 -0
  97. package/dist/weixin/node_modules/qiniu/qiniu/storage/rs.js +1764 -0
  98. package/dist/weixin/node_modules/qiniu/qiniu/util.js +382 -0
  99. package/dist/weixin/node_modules/qiniu/qiniu/zone.js +230 -0
  100. package/dist/weixin/node_modules/qiniu/tsconfig.json +112 -0
  101. package/dist/weixin/types.js +25 -0
  102. package/package.json +56 -0
@@ -0,0 +1,123 @@
1
+ var http = require('http');
2
+
3
+ const host = 'rtc.qiniuapi.com';
4
+ const headers = {
5
+ 'Content-Type': 'application/json'
6
+ };
7
+
8
+ function get(credentials, options, fn) {
9
+ options.headers.Authorization = credentials.generateAccessToken(options, null);
10
+
11
+ var req = http.request(options, function (res) {
12
+ res.setEncoding('utf-8');
13
+
14
+ var responseString = '';
15
+
16
+ res.on('data', function (data) {
17
+ responseString += data;
18
+ });
19
+
20
+ res.on('end', function () {
21
+ var resultObject = JSON.parse(responseString);
22
+
23
+ if (res.statusCode != 200) {
24
+ var result = {
25
+ code: res.statusCode,
26
+ message: resultObject.error || res.statusMessage,
27
+ reqId: res.headers['x-reqid']
28
+ };
29
+ fn(result, null);
30
+ } else {
31
+ fn(null, resultObject);
32
+ }
33
+ });
34
+ });
35
+
36
+ req.on('error', function (e) {
37
+ fn(e, null);
38
+ });
39
+
40
+ req.end();
41
+ }
42
+
43
+ function post(credentials, options, data, fn) {
44
+ var dataString = JSON.stringify(data);
45
+
46
+ options.headers.Authorization = credentials.generateAccessToken(options, dataString);
47
+
48
+ var req = http.request(options, function (res) {
49
+ res.setEncoding('utf-8');
50
+
51
+ var responseString = '';
52
+
53
+ res.on('data', function (data) {
54
+ responseString += data;
55
+ });
56
+
57
+ res.on('end', function () {
58
+ var resultObject = JSON.parse(responseString);
59
+
60
+ if (res.statusCode != 200) {
61
+ var result = {
62
+ code: res.statusCode,
63
+ message: resultObject.error || res.statusMessage,
64
+ reqId: res.headers['x-reqid']
65
+ };
66
+ fn(result, null);
67
+ } else {
68
+ fn(null, resultObject);
69
+ }
70
+ });
71
+ });
72
+ req.on('error', function (e) {
73
+ fn(e, null);
74
+ });
75
+
76
+ req.write(dataString);
77
+
78
+ req.end();
79
+ }
80
+
81
+ exports.createApp = function (app, credentials, fn) {
82
+ var options = {
83
+ host: host,
84
+ port: 80,
85
+ path: '/v3/apps',
86
+ method: 'POST',
87
+ headers: headers
88
+ };
89
+ post(credentials, options, app, fn);
90
+ };
91
+
92
+ exports.getApp = function (appId, credentials, fn) {
93
+ var options = {
94
+ host: host,
95
+ port: 80,
96
+ path: '/v3/apps/' + appId,
97
+ method: 'GET',
98
+ headers: headers
99
+ };
100
+ get(credentials, options, fn);
101
+ };
102
+
103
+ exports.deleteApp = function (appId, credentials, fn) {
104
+ var options = {
105
+ host: host,
106
+ port: 80,
107
+ path: '/v3/apps/' + appId,
108
+ method: 'DELETE',
109
+ headers: headers
110
+ };
111
+ get(credentials, options, fn);
112
+ };
113
+
114
+ exports.updateApp = function (appId, app, credentials, fn) {
115
+ var options = {
116
+ host: host,
117
+ port: 80,
118
+ path: '/v3/apps/' + appId,
119
+ method: 'POST',
120
+ headers: headers
121
+ };
122
+ post(credentials, options, app, fn);
123
+ };
@@ -0,0 +1,57 @@
1
+ var util = require('./util');
2
+
3
+ function Credentials (accessKey, secretKey) {
4
+ this.accessKey = accessKey;
5
+ this.secretKey = secretKey;
6
+ }
7
+
8
+ Credentials.prototype.generateAccessToken = function (options, data) {
9
+ var sign = this._signRequest(options, data);
10
+ var token = 'Qiniu' + ' ' + this.accessKey + ':' + sign;
11
+
12
+ return token;
13
+ };
14
+
15
+ Credentials.prototype._signRequest = function (options, body) {
16
+ var contentType = options.headers['Content-Type'];
17
+
18
+ var host = options.host;
19
+ if (options.port && options.port != 80) {
20
+ host = host + ':' + options.port;
21
+ }
22
+
23
+ var data = options.method + ' ' + options.path;
24
+ data += '\nHost: ' + host;
25
+ if (contentType) {
26
+ data += '\nContent-Type: ' + contentType;
27
+ }
28
+ data += '\n\n';
29
+
30
+ if (body && contentType && contentType != 'application/octet-stream') {
31
+ data += body;
32
+ }
33
+
34
+ var digest = util.hmacSha1(data, this.secretKey);
35
+
36
+ var sageDigest = util.base64ToUrlSafe(digest);
37
+
38
+ return sageDigest;
39
+ };
40
+
41
+ Credentials.prototype.sign = function (data) {
42
+ var digest = util.hmacSha1(data, this.secretKey);
43
+ var sageDigest = util.base64ToUrlSafe(digest);
44
+ return this.accessKey + ':' + sageDigest;
45
+ };
46
+
47
+ Credentials.prototype.signJson = function (opt) {
48
+ var str = JSON.stringify(opt);
49
+ var encodedStr = util.urlsafeBase64Encode(str);
50
+ var sign = util.hmacSha1(encodedStr, this.secretKey);
51
+ var encodedSign = util.base64ToUrlSafe(sign);
52
+
53
+ var token = this.accessKey + ':' + encodedSign + ':' + encodedStr;
54
+ return token;
55
+ };
56
+
57
+ module.exports = exports = Credentials;
@@ -0,0 +1,118 @@
1
+ var http = require('http');
2
+
3
+ const host = 'rtc.qiniuapi.com';
4
+ const headers = {
5
+ 'Content-Type': 'application/json'
6
+ };
7
+
8
+ function get (credentials, options, fn) {
9
+ options.headers.Authorization = credentials.generateAccessToken(options, null);
10
+
11
+ var req = http.request(options, function (res) {
12
+ res.setEncoding('utf-8');
13
+
14
+ var responseString = '';
15
+
16
+ res.on('data', function (data) {
17
+ responseString += data;
18
+ });
19
+
20
+ res.on('end', function () {
21
+ // var resultObject = JSON.parse(responseString);
22
+ // console.log(JSON.parse(responseString))
23
+
24
+ if (res.statusCode != 200) {
25
+ var result = {
26
+ code: res.statusCode,
27
+ message: res.statusMessage
28
+ };
29
+ fn(result, null);
30
+ } else {
31
+ fn(null, JSON.parse(responseString));
32
+ }
33
+ });
34
+ });
35
+
36
+ req.on('error', function (e) {
37
+ fn(e, null);
38
+ });
39
+
40
+ req.end();
41
+ }
42
+
43
+ // function post(credentials, options, data, fn) {
44
+ // var dataString = JSON.stringify(data);
45
+
46
+ // options.headers['Authorization'] = credentials.generateAccessToken(options, dataString);
47
+
48
+ // var req = http.request(options, function(res) {
49
+ // res.setEncoding('utf-8');
50
+
51
+ // var responseString = '';
52
+
53
+ // res.on('data', function(data) {
54
+ // responseString += data;
55
+ // });
56
+
57
+ // res.on('end', function() {
58
+ // var resultObject = JSON.parse(responseString);
59
+
60
+ // if (res.statusCode != 200) {
61
+ // var result = {
62
+ // code: res.statusCode,
63
+ // message: res.statusMessage
64
+ // };
65
+ // fn(result, null);
66
+ // } else {
67
+ // fn(null, resultObject);
68
+ // }
69
+ // });
70
+ // });
71
+ // req.on('error', function(e) {
72
+ // fn(e, null);
73
+ // });
74
+
75
+ // req.write(dataString);
76
+
77
+ // req.end();
78
+ // }
79
+
80
+ exports.listUser = function (appId, roomName, credentials, fn) {
81
+ var options = {
82
+ host: host,
83
+ port: 80,
84
+ path: '/v3/apps/' + appId + '/rooms/' + roomName + '/users',
85
+ method: 'GET',
86
+ headers: headers
87
+ };
88
+ get(credentials, options, fn);
89
+ };
90
+
91
+ exports.kickUser = function (appId, roomName, userId, credentials, fn) {
92
+ var options = {
93
+ host: host,
94
+ port: 80,
95
+ path: '/v3/apps/' + appId + '/rooms/' + roomName + '/users/' + userId,
96
+ method: 'DELETE',
97
+ headers: headers
98
+ };
99
+ get(credentials, options, fn);
100
+ };
101
+
102
+ exports.listActiveRooms = function (appId, roomNamePrefix, offset, limit, credentials, fn) {
103
+ var options = {
104
+ host: host,
105
+ port: 80,
106
+ path: '/v3/apps/' + appId + '/rooms?prefix=' + roomNamePrefix + '&offset=' + offset + '&limit=' + limit,
107
+ method: 'GET',
108
+ headers: headers
109
+ };
110
+ get(credentials, options, fn);
111
+ };
112
+
113
+ exports.getRoomToken = function (roomAccess, credentials) {
114
+ if (!roomAccess.expireAt) {
115
+ roomAccess.expireAt = Math.floor(Date.now() / 1000) + 3600;
116
+ }
117
+ return credentials.signJson(roomAccess);
118
+ };
@@ -0,0 +1,16 @@
1
+ var crypto = require('crypto');
2
+
3
+ exports.base64ToUrlSafe = function (v) {
4
+ return v.replace(/\//g, '_').replace(/\+/g, '-');
5
+ };
6
+
7
+ exports.urlsafeBase64Encode = function (jsonFlags) {
8
+ var encoded = Buffer.from(jsonFlags).toString('base64');
9
+ return exports.base64ToUrlSafe(encoded);
10
+ };
11
+
12
+ exports.hmacSha1 = function (encodedFlags, secretKey) {
13
+ var hmac = crypto.createHmac('sha1', secretKey);
14
+ hmac.update(encodedFlags);
15
+ return hmac.digest('base64');
16
+ };
@@ -0,0 +1,58 @@
1
+ const util = require('../util');
2
+ const urllib = require('urllib');
3
+ exports.sendMessage = function (reqBody,mac,callbackFunc){
4
+ reqBody = JSON.stringify(reqBody);
5
+ var args = {
6
+ requestURI:"https://sms.qiniuapi.com/v1/message",
7
+ reqBody:reqBody,
8
+ mac:mac,
9
+ }
10
+ post(args,callbackFunc);
11
+ }
12
+
13
+ exports.sendSingleMessage = function (reqBody,mac,callbackFunc){
14
+ reqBody = JSON.stringify(reqBody);
15
+ var args = {
16
+ requestURI:"https://sms.qiniuapi.com/v1/message/single",
17
+ reqBody:reqBody,
18
+ mac:mac,
19
+ }
20
+ post(args,callbackFunc);
21
+ }
22
+
23
+ exports.sendOverseaMessage = function (reqBody,mac,callbackFunc){
24
+ reqBody = JSON.stringify(reqBody);
25
+ var args = {
26
+ requestURI:"https://sms.qiniuapi.com/v1/message/oversea",
27
+ reqBody:reqBody,
28
+ mac:mac,
29
+ }
30
+ post(args,callbackFunc);
31
+ }
32
+
33
+ exports.sendFulltextMessage = function (reqBody,mac,callbackFunc){
34
+ reqBody = JSON.stringify(reqBody);
35
+ var args = {
36
+ requestURI:"https://sms.qiniuapi.com/v1/message/fulltext",
37
+ reqBody:reqBody,
38
+ mac:mac,
39
+ }
40
+ post(args,callbackFunc);
41
+ }
42
+
43
+ function post(args,callbackFunc){
44
+ var contentType = 'application/json';
45
+ var accessToken = util.generateAccessTokenV2(args.mac, args.requestURI, 'POST', contentType, args.reqBody);
46
+ var headers = {
47
+ 'Authorization': accessToken,
48
+ 'Content-Type': contentType,
49
+ }
50
+
51
+ var data = {
52
+ method: 'POST',
53
+ headers: headers,
54
+ data: args.reqBody,
55
+ }
56
+
57
+ urllib.request(args.requestURI, data, callbackFunc);
58
+ }