wuying-agentbay-sdk 0.1.0 → 0.3.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 +24 -4
- package/dist/index.cjs +4534 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +1837 -0
- package/dist/index.d.ts +1837 -0
- package/dist/index.mjs +4550 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +16 -8
- package/dist/src/adb/adb.d.ts +0 -20
- package/dist/src/adb/adb.js +0 -57
- package/dist/src/adb/index.d.ts +0 -1
- package/dist/src/adb/index.js +0 -17
- package/dist/src/agent-bay.d.ts +0 -68
- package/dist/src/agent-bay.js +0 -213
- package/dist/src/api/client.d.ts +0 -191
- package/dist/src/api/client.js +0 -629
- package/dist/src/api/index.d.ts +0 -4
- package/dist/src/api/index.js +0 -26
- package/dist/src/api/models/CallMcpToolRequest.d.ts +0 -21
- package/dist/src/api/models/CallMcpToolRequest.js +0 -71
- package/dist/src/api/models/CallMcpToolResponse.d.ts +0 -19
- package/dist/src/api/models/CallMcpToolResponse.js +0 -68
- package/dist/src/api/models/CallMcpToolResponseBody.d.ts +0 -19
- package/dist/src/api/models/CallMcpToolResponseBody.js +0 -67
- package/dist/src/api/models/CreateMcpSessionRequest.d.ts +0 -19
- package/dist/src/api/models/CreateMcpSessionRequest.js +0 -67
- package/dist/src/api/models/CreateMcpSessionResponse.d.ts +0 -19
- package/dist/src/api/models/CreateMcpSessionResponse.js +0 -68
- package/dist/src/api/models/CreateMcpSessionResponseBody.d.ts +0 -20
- package/dist/src/api/models/CreateMcpSessionResponseBody.js +0 -71
- package/dist/src/api/models/CreateMcpSessionResponseBodyData.d.ts +0 -19
- package/dist/src/api/models/CreateMcpSessionResponseBodyData.js +0 -67
- package/dist/src/api/models/DeleteContextRequest.d.ts +0 -15
- package/dist/src/api/models/DeleteContextRequest.js +0 -59
- package/dist/src/api/models/DeleteContextResponse.d.ts +0 -19
- package/dist/src/api/models/DeleteContextResponse.js +0 -68
- package/dist/src/api/models/DeleteContextResponseBody.d.ts +0 -18
- package/dist/src/api/models/DeleteContextResponseBody.js +0 -65
- package/dist/src/api/models/GetContextRequest.d.ts +0 -16
- package/dist/src/api/models/GetContextRequest.js +0 -61
- package/dist/src/api/models/GetContextResponse.d.ts +0 -19
- package/dist/src/api/models/GetContextResponse.js +0 -68
- package/dist/src/api/models/GetContextResponseBody.d.ts +0 -20
- package/dist/src/api/models/GetContextResponseBody.js +0 -71
- package/dist/src/api/models/GetContextResponseBodyData.d.ts +0 -19
- package/dist/src/api/models/GetContextResponseBodyData.js +0 -67
- package/dist/src/api/models/GetLabelRequest.d.ts +0 -17
- package/dist/src/api/models/GetLabelRequest.js +0 -63
- package/dist/src/api/models/GetLabelResponse.d.ts +0 -19
- package/dist/src/api/models/GetLabelResponse.js +0 -68
- package/dist/src/api/models/GetLabelResponseBody.d.ts +0 -23
- package/dist/src/api/models/GetLabelResponseBody.js +0 -77
- package/dist/src/api/models/GetLabelResponseBodyData.d.ts +0 -14
- package/dist/src/api/models/GetLabelResponseBodyData.js +0 -57
- package/dist/src/api/models/GetLinkRequest.d.ts +0 -15
- package/dist/src/api/models/GetLinkRequest.js +0 -59
- package/dist/src/api/models/GetLinkResponse.d.ts +0 -19
- package/dist/src/api/models/GetLinkResponse.js +0 -68
- package/dist/src/api/models/GetLinkResponseBody.d.ts +0 -19
- package/dist/src/api/models/GetLinkResponseBody.js +0 -67
- package/dist/src/api/models/GetMcpResourceRequest.d.ts +0 -15
- package/dist/src/api/models/GetMcpResourceRequest.js +0 -59
- package/dist/src/api/models/GetMcpResourceResponse.d.ts +0 -19
- package/dist/src/api/models/GetMcpResourceResponse.js +0 -68
- package/dist/src/api/models/GetMcpResourceResponseBody.d.ts +0 -20
- package/dist/src/api/models/GetMcpResourceResponseBody.js +0 -71
- package/dist/src/api/models/GetMcpResourceResponseBodyData.d.ts +0 -17
- package/dist/src/api/models/GetMcpResourceResponseBodyData.js +0 -65
- package/dist/src/api/models/GetMcpResourceResponseBodyDataDesktopInfo.d.ts +0 -18
- package/dist/src/api/models/GetMcpResourceResponseBodyDataDesktopInfo.js +0 -65
- package/dist/src/api/models/ListContextsRequest.d.ts +0 -16
- package/dist/src/api/models/ListContextsRequest.js +0 -61
- package/dist/src/api/models/ListContextsResponse.d.ts +0 -19
- package/dist/src/api/models/ListContextsResponse.js +0 -68
- package/dist/src/api/models/ListContextsResponseBody.d.ts +0 -23
- package/dist/src/api/models/ListContextsResponseBody.js +0 -77
- package/dist/src/api/models/ListContextsResponseBodyData.d.ts +0 -19
- package/dist/src/api/models/ListContextsResponseBodyData.js +0 -67
- package/dist/src/api/models/ListSessionRequest.d.ts +0 -17
- package/dist/src/api/models/ListSessionRequest.js +0 -63
- package/dist/src/api/models/ListSessionResponse.d.ts +0 -19
- package/dist/src/api/models/ListSessionResponse.js +0 -68
- package/dist/src/api/models/ListSessionResponseBody.d.ts +0 -23
- package/dist/src/api/models/ListSessionResponseBody.js +0 -77
- package/dist/src/api/models/ListSessionResponseBodyData.d.ts +0 -14
- package/dist/src/api/models/ListSessionResponseBodyData.js +0 -57
- package/dist/src/api/models/ModifyContextRequest.d.ts +0 -16
- package/dist/src/api/models/ModifyContextRequest.js +0 -61
- package/dist/src/api/models/ModifyContextResponse.d.ts +0 -19
- package/dist/src/api/models/ModifyContextResponse.js +0 -68
- package/dist/src/api/models/ModifyContextResponseBody.d.ts +0 -18
- package/dist/src/api/models/ModifyContextResponseBody.js +0 -65
- package/dist/src/api/models/ReleaseMcpSessionRequest.d.ts +0 -15
- package/dist/src/api/models/ReleaseMcpSessionRequest.js +0 -59
- package/dist/src/api/models/ReleaseMcpSessionResponse.d.ts +0 -19
- package/dist/src/api/models/ReleaseMcpSessionResponse.js +0 -68
- package/dist/src/api/models/ReleaseMcpSessionResponseBody.d.ts +0 -18
- package/dist/src/api/models/ReleaseMcpSessionResponseBody.js +0 -65
- package/dist/src/api/models/SetLabelRequest.d.ts +0 -16
- package/dist/src/api/models/SetLabelRequest.js +0 -61
- package/dist/src/api/models/SetLabelResponse.d.ts +0 -19
- package/dist/src/api/models/SetLabelResponse.js +0 -68
- package/dist/src/api/models/SetLabelResponseBody.d.ts +0 -18
- package/dist/src/api/models/SetLabelResponseBody.js +0 -65
- package/dist/src/api/models/model.d.ts +0 -43
- package/dist/src/api/models/model.js +0 -89
- package/dist/src/application/application.d.ts +0 -88
- package/dist/src/application/application.js +0 -172
- package/dist/src/application/index.d.ts +0 -1
- package/dist/src/application/index.js +0 -17
- package/dist/src/command/command.d.ts +0 -43
- package/dist/src/command/command.js +0 -120
- package/dist/src/command/index.d.ts +0 -1
- package/dist/src/command/index.js +0 -17
- package/dist/src/config.d.ts +0 -15
- package/dist/src/config.js +0 -114
- package/dist/src/context.d.ts +0 -87
- package/dist/src/context.js +0 -208
- package/dist/src/exceptions.d.ts +0 -30
- package/dist/src/exceptions.js +0 -58
- package/dist/src/filesystem/filesystem.d.ts +0 -109
- package/dist/src/filesystem/filesystem.js +0 -245
- package/dist/src/filesystem/index.d.ts +0 -1
- package/dist/src/filesystem/index.js +0 -17
- package/dist/src/index.d.ts +0 -10
- package/dist/src/index.js +0 -32
- package/dist/src/oss/index.d.ts +0 -1
- package/dist/src/oss/index.js +0 -5
- package/dist/src/oss/oss.d.ts +0 -80
- package/dist/src/oss/oss.js +0 -233
- package/dist/src/session.d.ts +0 -99
- package/dist/src/session.js +0 -226
- package/dist/src/ui/index.d.ts +0 -1
- package/dist/src/ui/index.js +0 -17
- package/dist/src/ui/ui.d.ts +0 -95
- package/dist/src/ui/ui.js +0 -206
- package/dist/src/utils/logger.d.ts +0 -15
- package/dist/src/utils/logger.js +0 -48
- package/dist/src/window/index.d.ts +0 -1
- package/dist/src/window/index.js +0 -17
- package/dist/src/window/window.d.ts +0 -109
- package/dist/src/window/window.js +0 -220
- package/dist/tests/agent-bay.test.d.ts +0 -1
- package/dist/tests/agent-bay.test.js +0 -366
- package/dist/tests/integration/context-persistence.test.d.ts +0 -1
- package/dist/tests/integration/context-persistence.test.js +0 -226
- package/dist/tests/integration/context-session.test.d.ts +0 -1
- package/dist/tests/integration/context-session.test.js +0 -223
- package/dist/tests/integration/window-operations.test.d.ts +0 -1
- package/dist/tests/integration/window-operations.test.js +0 -228
- package/dist/tests/unit/adb.test.d.ts +0 -1
- package/dist/tests/unit/adb.test.js +0 -60
- package/dist/tests/unit/agent-bay.test.d.ts +0 -1
- package/dist/tests/unit/agent-bay.test.js +0 -182
- package/dist/tests/unit/application.test.d.ts +0 -1
- package/dist/tests/unit/application.test.js +0 -260
- package/dist/tests/unit/command.test.d.ts +0 -1
- package/dist/tests/unit/command.test.js +0 -252
- package/dist/tests/unit/context.test.d.ts +0 -1
- package/dist/tests/unit/context.test.js +0 -199
- package/dist/tests/unit/filesystem.test.d.ts +0 -1
- package/dist/tests/unit/filesystem.test.js +0 -493
- package/dist/tests/unit/oss.test.d.ts +0 -1
- package/dist/tests/unit/oss.test.js +0 -243
- package/dist/tests/unit/session-labels.test.d.ts +0 -1
- package/dist/tests/unit/session-labels.test.js +0 -138
- package/dist/tests/unit/session-params.test.d.ts +0 -1
- package/dist/tests/unit/session-params.test.js +0 -78
- package/dist/tests/unit/session.test.d.ts +0 -1
- package/dist/tests/unit/session.test.js +0 -204
- package/dist/tests/unit/ui.test.d.ts +0 -1
- package/dist/tests/unit/ui.test.js +0 -158
- package/dist/tests/unit/window.test.d.ts +0 -1
- package/dist/tests/unit/window.test.js +0 -331
- package/dist/tests/utils/test-helpers.d.ts +0 -35
- package/dist/tests/utils/test-helpers.js +0 -79
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,4534 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
5
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
6
|
+
}) : x)(function(x) {
|
|
7
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
8
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
9
|
+
});
|
|
10
|
+
var __esm = (fn, res) => function __init() {
|
|
11
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
12
|
+
};
|
|
13
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// node_modules/tsup/assets/cjs_shims.js
|
|
18
|
+
var init_cjs_shims = __esm({
|
|
19
|
+
"node_modules/tsup/assets/cjs_shims.js"() {
|
|
20
|
+
"use strict";
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// node_modules/dotenv/package.json
|
|
25
|
+
var require_package = __commonJS({
|
|
26
|
+
"node_modules/dotenv/package.json"(exports, module) {
|
|
27
|
+
module.exports = {
|
|
28
|
+
name: "dotenv",
|
|
29
|
+
version: "16.5.0",
|
|
30
|
+
description: "Loads environment variables from .env file",
|
|
31
|
+
main: "lib/main.js",
|
|
32
|
+
types: "lib/main.d.ts",
|
|
33
|
+
exports: {
|
|
34
|
+
".": {
|
|
35
|
+
types: "./lib/main.d.ts",
|
|
36
|
+
require: "./lib/main.js",
|
|
37
|
+
default: "./lib/main.js"
|
|
38
|
+
},
|
|
39
|
+
"./config": "./config.js",
|
|
40
|
+
"./config.js": "./config.js",
|
|
41
|
+
"./lib/env-options": "./lib/env-options.js",
|
|
42
|
+
"./lib/env-options.js": "./lib/env-options.js",
|
|
43
|
+
"./lib/cli-options": "./lib/cli-options.js",
|
|
44
|
+
"./lib/cli-options.js": "./lib/cli-options.js",
|
|
45
|
+
"./package.json": "./package.json"
|
|
46
|
+
},
|
|
47
|
+
scripts: {
|
|
48
|
+
"dts-check": "tsc --project tests/types/tsconfig.json",
|
|
49
|
+
lint: "standard",
|
|
50
|
+
pretest: "npm run lint && npm run dts-check",
|
|
51
|
+
test: "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
52
|
+
"test:coverage": "tap run --show-full-coverage --timeout=60000 --coverage-report=lcov",
|
|
53
|
+
prerelease: "npm test",
|
|
54
|
+
release: "standard-version"
|
|
55
|
+
},
|
|
56
|
+
repository: {
|
|
57
|
+
type: "git",
|
|
58
|
+
url: "git://github.com/motdotla/dotenv.git"
|
|
59
|
+
},
|
|
60
|
+
homepage: "https://github.com/motdotla/dotenv#readme",
|
|
61
|
+
funding: "https://dotenvx.com",
|
|
62
|
+
keywords: [
|
|
63
|
+
"dotenv",
|
|
64
|
+
"env",
|
|
65
|
+
".env",
|
|
66
|
+
"environment",
|
|
67
|
+
"variables",
|
|
68
|
+
"config",
|
|
69
|
+
"settings"
|
|
70
|
+
],
|
|
71
|
+
readmeFilename: "README.md",
|
|
72
|
+
license: "BSD-2-Clause",
|
|
73
|
+
devDependencies: {
|
|
74
|
+
"@types/node": "^18.11.3",
|
|
75
|
+
decache: "^4.6.2",
|
|
76
|
+
sinon: "^14.0.1",
|
|
77
|
+
standard: "^17.0.0",
|
|
78
|
+
"standard-version": "^9.5.0",
|
|
79
|
+
tap: "^19.2.0",
|
|
80
|
+
typescript: "^4.8.4"
|
|
81
|
+
},
|
|
82
|
+
engines: {
|
|
83
|
+
node: ">=12"
|
|
84
|
+
},
|
|
85
|
+
browser: {
|
|
86
|
+
fs: false
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// node_modules/dotenv/lib/main.js
|
|
93
|
+
var require_main = __commonJS({
|
|
94
|
+
"node_modules/dotenv/lib/main.js"(exports, module) {
|
|
95
|
+
"use strict";
|
|
96
|
+
init_cjs_shims();
|
|
97
|
+
var fs2 = __require("fs");
|
|
98
|
+
var path2 = __require("path");
|
|
99
|
+
var os = __require("os");
|
|
100
|
+
var crypto = __require("crypto");
|
|
101
|
+
var packageJson = require_package();
|
|
102
|
+
var version = packageJson.version;
|
|
103
|
+
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
104
|
+
function parse(src) {
|
|
105
|
+
const obj = {};
|
|
106
|
+
let lines = src.toString();
|
|
107
|
+
lines = lines.replace(/\r\n?/mg, "\n");
|
|
108
|
+
let match;
|
|
109
|
+
while ((match = LINE.exec(lines)) != null) {
|
|
110
|
+
const key = match[1];
|
|
111
|
+
let value = match[2] || "";
|
|
112
|
+
value = value.trim();
|
|
113
|
+
const maybeQuote = value[0];
|
|
114
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
|
|
115
|
+
if (maybeQuote === '"') {
|
|
116
|
+
value = value.replace(/\\n/g, "\n");
|
|
117
|
+
value = value.replace(/\\r/g, "\r");
|
|
118
|
+
}
|
|
119
|
+
obj[key] = value;
|
|
120
|
+
}
|
|
121
|
+
return obj;
|
|
122
|
+
}
|
|
123
|
+
__name(parse, "parse");
|
|
124
|
+
function _parseVault(options) {
|
|
125
|
+
const vaultPath = _vaultPath(options);
|
|
126
|
+
const result = DotenvModule.configDotenv({ path: vaultPath });
|
|
127
|
+
if (!result.parsed) {
|
|
128
|
+
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
129
|
+
err.code = "MISSING_DATA";
|
|
130
|
+
throw err;
|
|
131
|
+
}
|
|
132
|
+
const keys = _dotenvKey(options).split(",");
|
|
133
|
+
const length = keys.length;
|
|
134
|
+
let decrypted;
|
|
135
|
+
for (let i = 0; i < length; i++) {
|
|
136
|
+
try {
|
|
137
|
+
const key = keys[i].trim();
|
|
138
|
+
const attrs = _instructions(result, key);
|
|
139
|
+
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
140
|
+
break;
|
|
141
|
+
} catch (error) {
|
|
142
|
+
if (i + 1 >= length) {
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return DotenvModule.parse(decrypted);
|
|
148
|
+
}
|
|
149
|
+
__name(_parseVault, "_parseVault");
|
|
150
|
+
function _warn(message) {
|
|
151
|
+
console.log(`[dotenv@${version}][WARN] ${message}`);
|
|
152
|
+
}
|
|
153
|
+
__name(_warn, "_warn");
|
|
154
|
+
function _debug(message) {
|
|
155
|
+
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
|
156
|
+
}
|
|
157
|
+
__name(_debug, "_debug");
|
|
158
|
+
function _dotenvKey(options) {
|
|
159
|
+
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
|
160
|
+
return options.DOTENV_KEY;
|
|
161
|
+
}
|
|
162
|
+
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
|
163
|
+
return process.env.DOTENV_KEY;
|
|
164
|
+
}
|
|
165
|
+
return "";
|
|
166
|
+
}
|
|
167
|
+
__name(_dotenvKey, "_dotenvKey");
|
|
168
|
+
function _instructions(result, dotenvKey) {
|
|
169
|
+
let uri;
|
|
170
|
+
try {
|
|
171
|
+
uri = new URL(dotenvKey);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
if (error.code === "ERR_INVALID_URL") {
|
|
174
|
+
const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
|
|
175
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
176
|
+
throw err;
|
|
177
|
+
}
|
|
178
|
+
throw error;
|
|
179
|
+
}
|
|
180
|
+
const key = uri.password;
|
|
181
|
+
if (!key) {
|
|
182
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
183
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
184
|
+
throw err;
|
|
185
|
+
}
|
|
186
|
+
const environment = uri.searchParams.get("environment");
|
|
187
|
+
if (!environment) {
|
|
188
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
189
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
190
|
+
throw err;
|
|
191
|
+
}
|
|
192
|
+
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
193
|
+
const ciphertext = result.parsed[environmentKey];
|
|
194
|
+
if (!ciphertext) {
|
|
195
|
+
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
196
|
+
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
|
197
|
+
throw err;
|
|
198
|
+
}
|
|
199
|
+
return { ciphertext, key };
|
|
200
|
+
}
|
|
201
|
+
__name(_instructions, "_instructions");
|
|
202
|
+
function _vaultPath(options) {
|
|
203
|
+
let possibleVaultPath = null;
|
|
204
|
+
if (options && options.path && options.path.length > 0) {
|
|
205
|
+
if (Array.isArray(options.path)) {
|
|
206
|
+
for (const filepath of options.path) {
|
|
207
|
+
if (fs2.existsSync(filepath)) {
|
|
208
|
+
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
213
|
+
}
|
|
214
|
+
} else {
|
|
215
|
+
possibleVaultPath = path2.resolve(process.cwd(), ".env.vault");
|
|
216
|
+
}
|
|
217
|
+
if (fs2.existsSync(possibleVaultPath)) {
|
|
218
|
+
return possibleVaultPath;
|
|
219
|
+
}
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
__name(_vaultPath, "_vaultPath");
|
|
223
|
+
function _resolveHome(envPath) {
|
|
224
|
+
return envPath[0] === "~" ? path2.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
225
|
+
}
|
|
226
|
+
__name(_resolveHome, "_resolveHome");
|
|
227
|
+
function _configVault(options) {
|
|
228
|
+
const debug = Boolean(options && options.debug);
|
|
229
|
+
if (debug) {
|
|
230
|
+
_debug("Loading env from encrypted .env.vault");
|
|
231
|
+
}
|
|
232
|
+
const parsed = DotenvModule._parseVault(options);
|
|
233
|
+
let processEnv = process.env;
|
|
234
|
+
if (options && options.processEnv != null) {
|
|
235
|
+
processEnv = options.processEnv;
|
|
236
|
+
}
|
|
237
|
+
DotenvModule.populate(processEnv, parsed, options);
|
|
238
|
+
return { parsed };
|
|
239
|
+
}
|
|
240
|
+
__name(_configVault, "_configVault");
|
|
241
|
+
function configDotenv(options) {
|
|
242
|
+
const dotenvPath = path2.resolve(process.cwd(), ".env");
|
|
243
|
+
let encoding = "utf8";
|
|
244
|
+
const debug = Boolean(options && options.debug);
|
|
245
|
+
if (options && options.encoding) {
|
|
246
|
+
encoding = options.encoding;
|
|
247
|
+
} else {
|
|
248
|
+
if (debug) {
|
|
249
|
+
_debug("No encoding is specified. UTF-8 is used by default");
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
let optionPaths = [dotenvPath];
|
|
253
|
+
if (options && options.path) {
|
|
254
|
+
if (!Array.isArray(options.path)) {
|
|
255
|
+
optionPaths = [_resolveHome(options.path)];
|
|
256
|
+
} else {
|
|
257
|
+
optionPaths = [];
|
|
258
|
+
for (const filepath of options.path) {
|
|
259
|
+
optionPaths.push(_resolveHome(filepath));
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
let lastError;
|
|
264
|
+
const parsedAll = {};
|
|
265
|
+
for (const path3 of optionPaths) {
|
|
266
|
+
try {
|
|
267
|
+
const parsed = DotenvModule.parse(fs2.readFileSync(path3, { encoding }));
|
|
268
|
+
DotenvModule.populate(parsedAll, parsed, options);
|
|
269
|
+
} catch (e) {
|
|
270
|
+
if (debug) {
|
|
271
|
+
_debug(`Failed to load ${path3} ${e.message}`);
|
|
272
|
+
}
|
|
273
|
+
lastError = e;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
let processEnv = process.env;
|
|
277
|
+
if (options && options.processEnv != null) {
|
|
278
|
+
processEnv = options.processEnv;
|
|
279
|
+
}
|
|
280
|
+
DotenvModule.populate(processEnv, parsedAll, options);
|
|
281
|
+
if (lastError) {
|
|
282
|
+
return { parsed: parsedAll, error: lastError };
|
|
283
|
+
} else {
|
|
284
|
+
return { parsed: parsedAll };
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
__name(configDotenv, "configDotenv");
|
|
288
|
+
function config(options) {
|
|
289
|
+
if (_dotenvKey(options).length === 0) {
|
|
290
|
+
return DotenvModule.configDotenv(options);
|
|
291
|
+
}
|
|
292
|
+
const vaultPath = _vaultPath(options);
|
|
293
|
+
if (!vaultPath) {
|
|
294
|
+
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
|
295
|
+
return DotenvModule.configDotenv(options);
|
|
296
|
+
}
|
|
297
|
+
return DotenvModule._configVault(options);
|
|
298
|
+
}
|
|
299
|
+
__name(config, "config");
|
|
300
|
+
function decrypt(encrypted, keyStr) {
|
|
301
|
+
const key = Buffer.from(keyStr.slice(-64), "hex");
|
|
302
|
+
let ciphertext = Buffer.from(encrypted, "base64");
|
|
303
|
+
const nonce = ciphertext.subarray(0, 12);
|
|
304
|
+
const authTag = ciphertext.subarray(-16);
|
|
305
|
+
ciphertext = ciphertext.subarray(12, -16);
|
|
306
|
+
try {
|
|
307
|
+
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
|
308
|
+
aesgcm.setAuthTag(authTag);
|
|
309
|
+
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
310
|
+
} catch (error) {
|
|
311
|
+
const isRange = error instanceof RangeError;
|
|
312
|
+
const invalidKeyLength = error.message === "Invalid key length";
|
|
313
|
+
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
|
314
|
+
if (isRange || invalidKeyLength) {
|
|
315
|
+
const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
316
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
317
|
+
throw err;
|
|
318
|
+
} else if (decryptionFailed) {
|
|
319
|
+
const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
320
|
+
err.code = "DECRYPTION_FAILED";
|
|
321
|
+
throw err;
|
|
322
|
+
} else {
|
|
323
|
+
throw error;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
__name(decrypt, "decrypt");
|
|
328
|
+
function populate(processEnv, parsed, options = {}) {
|
|
329
|
+
const debug = Boolean(options && options.debug);
|
|
330
|
+
const override = Boolean(options && options.override);
|
|
331
|
+
if (typeof parsed !== "object") {
|
|
332
|
+
const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
333
|
+
err.code = "OBJECT_REQUIRED";
|
|
334
|
+
throw err;
|
|
335
|
+
}
|
|
336
|
+
for (const key of Object.keys(parsed)) {
|
|
337
|
+
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
338
|
+
if (override === true) {
|
|
339
|
+
processEnv[key] = parsed[key];
|
|
340
|
+
}
|
|
341
|
+
if (debug) {
|
|
342
|
+
if (override === true) {
|
|
343
|
+
_debug(`"${key}" is already defined and WAS overwritten`);
|
|
344
|
+
} else {
|
|
345
|
+
_debug(`"${key}" is already defined and was NOT overwritten`);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
} else {
|
|
349
|
+
processEnv[key] = parsed[key];
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
__name(populate, "populate");
|
|
354
|
+
var DotenvModule = {
|
|
355
|
+
configDotenv,
|
|
356
|
+
_configVault,
|
|
357
|
+
_parseVault,
|
|
358
|
+
config,
|
|
359
|
+
decrypt,
|
|
360
|
+
parse,
|
|
361
|
+
populate
|
|
362
|
+
};
|
|
363
|
+
module.exports.configDotenv = DotenvModule.configDotenv;
|
|
364
|
+
module.exports._configVault = DotenvModule._configVault;
|
|
365
|
+
module.exports._parseVault = DotenvModule._parseVault;
|
|
366
|
+
module.exports.config = DotenvModule.config;
|
|
367
|
+
module.exports.decrypt = DotenvModule.decrypt;
|
|
368
|
+
module.exports.parse = DotenvModule.parse;
|
|
369
|
+
module.exports.populate = DotenvModule.populate;
|
|
370
|
+
module.exports = DotenvModule;
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
// node_modules/dotenv/lib/env-options.js
|
|
375
|
+
var require_env_options = __commonJS({
|
|
376
|
+
"node_modules/dotenv/lib/env-options.js"(exports, module) {
|
|
377
|
+
"use strict";
|
|
378
|
+
init_cjs_shims();
|
|
379
|
+
var options = {};
|
|
380
|
+
if (process.env.DOTENV_CONFIG_ENCODING != null) {
|
|
381
|
+
options.encoding = process.env.DOTENV_CONFIG_ENCODING;
|
|
382
|
+
}
|
|
383
|
+
if (process.env.DOTENV_CONFIG_PATH != null) {
|
|
384
|
+
options.path = process.env.DOTENV_CONFIG_PATH;
|
|
385
|
+
}
|
|
386
|
+
if (process.env.DOTENV_CONFIG_DEBUG != null) {
|
|
387
|
+
options.debug = process.env.DOTENV_CONFIG_DEBUG;
|
|
388
|
+
}
|
|
389
|
+
if (process.env.DOTENV_CONFIG_OVERRIDE != null) {
|
|
390
|
+
options.override = process.env.DOTENV_CONFIG_OVERRIDE;
|
|
391
|
+
}
|
|
392
|
+
if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {
|
|
393
|
+
options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY;
|
|
394
|
+
}
|
|
395
|
+
module.exports = options;
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
// node_modules/dotenv/lib/cli-options.js
|
|
400
|
+
var require_cli_options = __commonJS({
|
|
401
|
+
"node_modules/dotenv/lib/cli-options.js"(exports, module) {
|
|
402
|
+
"use strict";
|
|
403
|
+
init_cjs_shims();
|
|
404
|
+
var re = /^dotenv_config_(encoding|path|debug|override|DOTENV_KEY)=(.+)$/;
|
|
405
|
+
module.exports = /* @__PURE__ */ __name(function optionMatcher(args) {
|
|
406
|
+
return args.reduce(function(acc, cur) {
|
|
407
|
+
const matches = cur.match(re);
|
|
408
|
+
if (matches) {
|
|
409
|
+
acc[matches[1]] = matches[2];
|
|
410
|
+
}
|
|
411
|
+
return acc;
|
|
412
|
+
}, {});
|
|
413
|
+
}, "optionMatcher");
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
// src/index.ts
|
|
418
|
+
init_cjs_shims();
|
|
419
|
+
|
|
420
|
+
// src/agent-bay.ts
|
|
421
|
+
init_cjs_shims();
|
|
422
|
+
|
|
423
|
+
// src/session.ts
|
|
424
|
+
init_cjs_shims();
|
|
425
|
+
|
|
426
|
+
// src/exceptions.ts
|
|
427
|
+
init_cjs_shims();
|
|
428
|
+
var _AgentBayError = class _AgentBayError extends Error {
|
|
429
|
+
constructor(message) {
|
|
430
|
+
super(message);
|
|
431
|
+
this.name = "AgentBayError";
|
|
432
|
+
Object.setPrototypeOf(this, _AgentBayError.prototype);
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
__name(_AgentBayError, "AgentBayError");
|
|
436
|
+
var AgentBayError = _AgentBayError;
|
|
437
|
+
var _AuthenticationError = class _AuthenticationError extends AgentBayError {
|
|
438
|
+
constructor(message) {
|
|
439
|
+
super(message);
|
|
440
|
+
this.name = "AuthenticationError";
|
|
441
|
+
Object.setPrototypeOf(this, _AuthenticationError.prototype);
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
__name(_AuthenticationError, "AuthenticationError");
|
|
445
|
+
var AuthenticationError = _AuthenticationError;
|
|
446
|
+
var _APIError = class _APIError extends AgentBayError {
|
|
447
|
+
constructor(message) {
|
|
448
|
+
super(message);
|
|
449
|
+
this.name = "APIError";
|
|
450
|
+
Object.setPrototypeOf(this, _APIError.prototype);
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
__name(_APIError, "APIError");
|
|
454
|
+
var APIError = _APIError;
|
|
455
|
+
var _FileError = class _FileError extends AgentBayError {
|
|
456
|
+
constructor(message) {
|
|
457
|
+
super(message);
|
|
458
|
+
this.name = "FileError";
|
|
459
|
+
Object.setPrototypeOf(this, _FileError.prototype);
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
__name(_FileError, "FileError");
|
|
463
|
+
var FileError = _FileError;
|
|
464
|
+
var _CommandError = class _CommandError extends AgentBayError {
|
|
465
|
+
constructor(message) {
|
|
466
|
+
super(message);
|
|
467
|
+
this.name = "CommandError";
|
|
468
|
+
Object.setPrototypeOf(this, _CommandError.prototype);
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
__name(_CommandError, "CommandError");
|
|
472
|
+
var CommandError = _CommandError;
|
|
473
|
+
|
|
474
|
+
// src/filesystem/filesystem.ts
|
|
475
|
+
init_cjs_shims();
|
|
476
|
+
|
|
477
|
+
// src/api/models/model.ts
|
|
478
|
+
init_cjs_shims();
|
|
479
|
+
|
|
480
|
+
// src/api/models/CreateMcpSessionResponseBodyData.ts
|
|
481
|
+
init_cjs_shims();
|
|
482
|
+
var _typescript = require('@darabonba/typescript'); var $dara = _interopRequireWildcard(_typescript); var $dara2 = _interopRequireWildcard(_typescript); var $dara3 = _interopRequireWildcard(_typescript); var $dara4 = _interopRequireWildcard(_typescript); var $dara5 = _interopRequireWildcard(_typescript); var $dara6 = _interopRequireWildcard(_typescript); var $dara7 = _interopRequireWildcard(_typescript); var $dara8 = _interopRequireWildcard(_typescript); var $dara9 = _interopRequireWildcard(_typescript); var $dara10 = _interopRequireWildcard(_typescript); var $dara11 = _interopRequireWildcard(_typescript); var $dara12 = _interopRequireWildcard(_typescript); var $dara13 = _interopRequireWildcard(_typescript); var $dara14 = _interopRequireWildcard(_typescript); var $dara15 = _interopRequireWildcard(_typescript); var $dara16 = _interopRequireWildcard(_typescript); var $dara17 = _interopRequireWildcard(_typescript); var $dara18 = _interopRequireWildcard(_typescript); var $dara19 = _interopRequireWildcard(_typescript); var $dara20 = _interopRequireWildcard(_typescript); var $dara21 = _interopRequireWildcard(_typescript); var $dara22 = _interopRequireWildcard(_typescript); var $dara23 = _interopRequireWildcard(_typescript); var $dara24 = _interopRequireWildcard(_typescript); var $dara25 = _interopRequireWildcard(_typescript); var $dara26 = _interopRequireWildcard(_typescript); var $dara27 = _interopRequireWildcard(_typescript); var $dara28 = _interopRequireWildcard(_typescript); var $dara29 = _interopRequireWildcard(_typescript); var $dara30 = _interopRequireWildcard(_typescript); var $dara31 = _interopRequireWildcard(_typescript); var $dara32 = _interopRequireWildcard(_typescript); var $dara33 = _interopRequireWildcard(_typescript); var $dara34 = _interopRequireWildcard(_typescript); var $dara35 = _interopRequireWildcard(_typescript); var $dara36 = _interopRequireWildcard(_typescript); var $dara37 = _interopRequireWildcard(_typescript); var $dara38 = _interopRequireWildcard(_typescript); var $dara39 = _interopRequireWildcard(_typescript); var $dara40 = _interopRequireWildcard(_typescript); var $dara41 = _interopRequireWildcard(_typescript); var $dara42 = _interopRequireWildcard(_typescript); var $dara43 = _interopRequireWildcard(_typescript); var $dara44 = _interopRequireWildcard(_typescript);
|
|
483
|
+
var _CreateMcpSessionResponseBodyData = class _CreateMcpSessionResponseBodyData extends $dara.Model {
|
|
484
|
+
static names() {
|
|
485
|
+
return {
|
|
486
|
+
appInstanceId: "AppInstanceId",
|
|
487
|
+
errMsg: "ErrMsg",
|
|
488
|
+
resourceId: "ResourceId",
|
|
489
|
+
resourceUrl: "ResourceUrl",
|
|
490
|
+
sessionId: "SessionId",
|
|
491
|
+
success: "Success"
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
static types() {
|
|
495
|
+
return {
|
|
496
|
+
appInstanceId: "string",
|
|
497
|
+
errMsg: "string",
|
|
498
|
+
resourceId: "string",
|
|
499
|
+
resourceUrl: "string",
|
|
500
|
+
sessionId: "string",
|
|
501
|
+
success: "boolean"
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
validate() {
|
|
505
|
+
super.validate();
|
|
506
|
+
}
|
|
507
|
+
constructor(map) {
|
|
508
|
+
super(map);
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
__name(_CreateMcpSessionResponseBodyData, "CreateMcpSessionResponseBodyData");
|
|
512
|
+
var CreateMcpSessionResponseBodyData = _CreateMcpSessionResponseBodyData;
|
|
513
|
+
|
|
514
|
+
// src/api/models/GetContextResponseBodyData.ts
|
|
515
|
+
init_cjs_shims();
|
|
516
|
+
|
|
517
|
+
var _GetContextResponseBodyData = class _GetContextResponseBodyData extends $dara2.Model {
|
|
518
|
+
static names() {
|
|
519
|
+
return {
|
|
520
|
+
createTime: "CreateTime",
|
|
521
|
+
id: "Id",
|
|
522
|
+
lastUsedTime: "LastUsedTime",
|
|
523
|
+
name: "Name",
|
|
524
|
+
osType: "OsType",
|
|
525
|
+
state: "State"
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
static types() {
|
|
529
|
+
return {
|
|
530
|
+
createTime: "string",
|
|
531
|
+
id: "string",
|
|
532
|
+
lastUsedTime: "string",
|
|
533
|
+
name: "string",
|
|
534
|
+
osType: "string",
|
|
535
|
+
state: "string"
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
validate() {
|
|
539
|
+
super.validate();
|
|
540
|
+
}
|
|
541
|
+
constructor(map) {
|
|
542
|
+
super(map);
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
__name(_GetContextResponseBodyData, "GetContextResponseBodyData");
|
|
546
|
+
var GetContextResponseBodyData = _GetContextResponseBodyData;
|
|
547
|
+
|
|
548
|
+
// src/api/models/GetLabelResponseBodyData.ts
|
|
549
|
+
init_cjs_shims();
|
|
550
|
+
|
|
551
|
+
var _GetLabelResponseBodyData = class _GetLabelResponseBodyData extends $dara3.Model {
|
|
552
|
+
static names() {
|
|
553
|
+
return {
|
|
554
|
+
labels: "Labels"
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
static types() {
|
|
558
|
+
return {
|
|
559
|
+
labels: "string"
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
validate() {
|
|
563
|
+
super.validate();
|
|
564
|
+
}
|
|
565
|
+
constructor(map) {
|
|
566
|
+
super(map);
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
__name(_GetLabelResponseBodyData, "GetLabelResponseBodyData");
|
|
570
|
+
var GetLabelResponseBodyData = _GetLabelResponseBodyData;
|
|
571
|
+
|
|
572
|
+
// src/api/models/GetMcpResourceResponseBodyDataDesktopInfo.ts
|
|
573
|
+
init_cjs_shims();
|
|
574
|
+
|
|
575
|
+
var _GetMcpResourceResponseBodyDataDesktopInfo = class _GetMcpResourceResponseBodyDataDesktopInfo extends $dara4.Model {
|
|
576
|
+
static names() {
|
|
577
|
+
return {
|
|
578
|
+
appId: "AppId",
|
|
579
|
+
authCode: "AuthCode",
|
|
580
|
+
connectionProperties: "ConnectionProperties",
|
|
581
|
+
resourceId: "ResourceId",
|
|
582
|
+
resourceType: "ResourceType"
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
static types() {
|
|
586
|
+
return {
|
|
587
|
+
appId: "string",
|
|
588
|
+
authCode: "string",
|
|
589
|
+
connectionProperties: "string",
|
|
590
|
+
resourceId: "string",
|
|
591
|
+
resourceType: "string"
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
validate() {
|
|
595
|
+
super.validate();
|
|
596
|
+
}
|
|
597
|
+
constructor(map) {
|
|
598
|
+
super(map);
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
__name(_GetMcpResourceResponseBodyDataDesktopInfo, "GetMcpResourceResponseBodyDataDesktopInfo");
|
|
602
|
+
var GetMcpResourceResponseBodyDataDesktopInfo = _GetMcpResourceResponseBodyDataDesktopInfo;
|
|
603
|
+
|
|
604
|
+
// src/api/models/GetMcpResourceResponseBodyData.ts
|
|
605
|
+
init_cjs_shims();
|
|
606
|
+
|
|
607
|
+
var _GetMcpResourceResponseBodyData = class _GetMcpResourceResponseBodyData extends $dara5.Model {
|
|
608
|
+
static names() {
|
|
609
|
+
return {
|
|
610
|
+
desktopInfo: "DesktopInfo",
|
|
611
|
+
resourceUrl: "ResourceUrl",
|
|
612
|
+
sessionId: "SessionId"
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
static types() {
|
|
616
|
+
return {
|
|
617
|
+
desktopInfo: GetMcpResourceResponseBodyDataDesktopInfo,
|
|
618
|
+
resourceUrl: "string",
|
|
619
|
+
sessionId: "string"
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
validate() {
|
|
623
|
+
if (this.desktopInfo && typeof this.desktopInfo.validate === "function") {
|
|
624
|
+
this.desktopInfo.validate();
|
|
625
|
+
}
|
|
626
|
+
super.validate();
|
|
627
|
+
}
|
|
628
|
+
constructor(map) {
|
|
629
|
+
super(map);
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
__name(_GetMcpResourceResponseBodyData, "GetMcpResourceResponseBodyData");
|
|
633
|
+
var GetMcpResourceResponseBodyData = _GetMcpResourceResponseBodyData;
|
|
634
|
+
|
|
635
|
+
// src/api/models/ListContextsResponseBodyData.ts
|
|
636
|
+
init_cjs_shims();
|
|
637
|
+
|
|
638
|
+
var _ListContextsResponseBodyData = class _ListContextsResponseBodyData extends $dara6.Model {
|
|
639
|
+
static names() {
|
|
640
|
+
return {
|
|
641
|
+
createTime: "CreateTime",
|
|
642
|
+
id: "Id",
|
|
643
|
+
lastUsedTime: "LastUsedTime",
|
|
644
|
+
name: "Name",
|
|
645
|
+
osType: "OsType",
|
|
646
|
+
state: "State"
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
static types() {
|
|
650
|
+
return {
|
|
651
|
+
createTime: "string",
|
|
652
|
+
id: "string",
|
|
653
|
+
lastUsedTime: "string",
|
|
654
|
+
name: "string",
|
|
655
|
+
osType: "string",
|
|
656
|
+
state: "string"
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
validate() {
|
|
660
|
+
super.validate();
|
|
661
|
+
}
|
|
662
|
+
constructor(map) {
|
|
663
|
+
super(map);
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
__name(_ListContextsResponseBodyData, "ListContextsResponseBodyData");
|
|
667
|
+
var ListContextsResponseBodyData = _ListContextsResponseBodyData;
|
|
668
|
+
|
|
669
|
+
// src/api/models/ListSessionResponseBodyData.ts
|
|
670
|
+
init_cjs_shims();
|
|
671
|
+
|
|
672
|
+
var _ListSessionResponseBodyData = class _ListSessionResponseBodyData extends $dara7.Model {
|
|
673
|
+
static names() {
|
|
674
|
+
return {
|
|
675
|
+
sessionId: "SessionId"
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
static types() {
|
|
679
|
+
return {
|
|
680
|
+
sessionId: "string"
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
validate() {
|
|
684
|
+
super.validate();
|
|
685
|
+
}
|
|
686
|
+
constructor(map) {
|
|
687
|
+
super(map);
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
__name(_ListSessionResponseBodyData, "ListSessionResponseBodyData");
|
|
691
|
+
var ListSessionResponseBodyData = _ListSessionResponseBodyData;
|
|
692
|
+
|
|
693
|
+
// src/api/models/CallMcpToolRequest.ts
|
|
694
|
+
init_cjs_shims();
|
|
695
|
+
|
|
696
|
+
var _CallMcpToolRequest = class _CallMcpToolRequest extends $dara8.Model {
|
|
697
|
+
static names() {
|
|
698
|
+
return {
|
|
699
|
+
args: "Args",
|
|
700
|
+
authorization: "Authorization",
|
|
701
|
+
externalUserId: "ExternalUserId",
|
|
702
|
+
imageId: "ImageId",
|
|
703
|
+
name: "Name",
|
|
704
|
+
server: "Server",
|
|
705
|
+
sessionId: "SessionId",
|
|
706
|
+
tool: "Tool"
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
static types() {
|
|
710
|
+
return {
|
|
711
|
+
args: "string",
|
|
712
|
+
authorization: "string",
|
|
713
|
+
externalUserId: "string",
|
|
714
|
+
imageId: "string",
|
|
715
|
+
name: "string",
|
|
716
|
+
server: "string",
|
|
717
|
+
sessionId: "string",
|
|
718
|
+
tool: "string"
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
validate() {
|
|
722
|
+
super.validate();
|
|
723
|
+
}
|
|
724
|
+
constructor(map) {
|
|
725
|
+
super(map);
|
|
726
|
+
}
|
|
727
|
+
};
|
|
728
|
+
__name(_CallMcpToolRequest, "CallMcpToolRequest");
|
|
729
|
+
var CallMcpToolRequest = _CallMcpToolRequest;
|
|
730
|
+
|
|
731
|
+
// src/api/models/CallMcpToolResponseBody.ts
|
|
732
|
+
init_cjs_shims();
|
|
733
|
+
|
|
734
|
+
var _CallMcpToolResponseBody = class _CallMcpToolResponseBody extends $dara9.Model {
|
|
735
|
+
static names() {
|
|
736
|
+
return {
|
|
737
|
+
code: "Code",
|
|
738
|
+
data: "Data",
|
|
739
|
+
httpStatusCode: "HttpStatusCode",
|
|
740
|
+
message: "Message",
|
|
741
|
+
requestId: "RequestId",
|
|
742
|
+
success: "Success"
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
static types() {
|
|
746
|
+
return {
|
|
747
|
+
code: "string",
|
|
748
|
+
data: "any",
|
|
749
|
+
httpStatusCode: "number",
|
|
750
|
+
message: "string",
|
|
751
|
+
requestId: "string",
|
|
752
|
+
success: "boolean"
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
validate() {
|
|
756
|
+
super.validate();
|
|
757
|
+
}
|
|
758
|
+
constructor(map) {
|
|
759
|
+
super(map);
|
|
760
|
+
}
|
|
761
|
+
};
|
|
762
|
+
__name(_CallMcpToolResponseBody, "CallMcpToolResponseBody");
|
|
763
|
+
var CallMcpToolResponseBody = _CallMcpToolResponseBody;
|
|
764
|
+
|
|
765
|
+
// src/api/models/CallMcpToolResponse.ts
|
|
766
|
+
init_cjs_shims();
|
|
767
|
+
|
|
768
|
+
var _CallMcpToolResponse = class _CallMcpToolResponse extends $dara10.Model {
|
|
769
|
+
static names() {
|
|
770
|
+
return {
|
|
771
|
+
headers: "headers",
|
|
772
|
+
statusCode: "statusCode",
|
|
773
|
+
body: "body"
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
static types() {
|
|
777
|
+
return {
|
|
778
|
+
headers: { "type": "map", "keyType": "string", "valueType": "string" },
|
|
779
|
+
statusCode: "number",
|
|
780
|
+
body: CallMcpToolResponseBody
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
validate() {
|
|
784
|
+
if (this.headers) {
|
|
785
|
+
$dara10.Model.validateMap(this.headers);
|
|
786
|
+
}
|
|
787
|
+
if (this.body && typeof this.body.validate === "function") {
|
|
788
|
+
this.body.validate();
|
|
789
|
+
}
|
|
790
|
+
super.validate();
|
|
791
|
+
}
|
|
792
|
+
constructor(map) {
|
|
793
|
+
super(map);
|
|
794
|
+
}
|
|
795
|
+
};
|
|
796
|
+
__name(_CallMcpToolResponse, "CallMcpToolResponse");
|
|
797
|
+
var CallMcpToolResponse = _CallMcpToolResponse;
|
|
798
|
+
|
|
799
|
+
// src/api/models/CreateMcpSessionRequest.ts
|
|
800
|
+
init_cjs_shims();
|
|
801
|
+
|
|
802
|
+
var _CreateMcpSessionRequest = class _CreateMcpSessionRequest extends $dara11.Model {
|
|
803
|
+
static names() {
|
|
804
|
+
return {
|
|
805
|
+
authorization: "Authorization",
|
|
806
|
+
contextId: "ContextId",
|
|
807
|
+
externalUserId: "ExternalUserId",
|
|
808
|
+
imageId: "ImageId",
|
|
809
|
+
labels: "Labels",
|
|
810
|
+
sessionId: "SessionId"
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
static types() {
|
|
814
|
+
return {
|
|
815
|
+
authorization: "string",
|
|
816
|
+
contextId: "string",
|
|
817
|
+
externalUserId: "string",
|
|
818
|
+
imageId: "string",
|
|
819
|
+
labels: "string",
|
|
820
|
+
sessionId: "string"
|
|
821
|
+
};
|
|
822
|
+
}
|
|
823
|
+
validate() {
|
|
824
|
+
super.validate();
|
|
825
|
+
}
|
|
826
|
+
constructor(map) {
|
|
827
|
+
super(map);
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
__name(_CreateMcpSessionRequest, "CreateMcpSessionRequest");
|
|
831
|
+
var CreateMcpSessionRequest = _CreateMcpSessionRequest;
|
|
832
|
+
|
|
833
|
+
// src/api/models/CreateMcpSessionResponseBody.ts
|
|
834
|
+
init_cjs_shims();
|
|
835
|
+
|
|
836
|
+
var _CreateMcpSessionResponseBody = class _CreateMcpSessionResponseBody extends $dara12.Model {
|
|
837
|
+
static names() {
|
|
838
|
+
return {
|
|
839
|
+
code: "Code",
|
|
840
|
+
data: "Data",
|
|
841
|
+
httpStatusCode: "HttpStatusCode",
|
|
842
|
+
message: "Message",
|
|
843
|
+
requestId: "RequestId",
|
|
844
|
+
success: "Success"
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
static types() {
|
|
848
|
+
return {
|
|
849
|
+
code: "string",
|
|
850
|
+
data: CreateMcpSessionResponseBodyData,
|
|
851
|
+
httpStatusCode: "number",
|
|
852
|
+
message: "string",
|
|
853
|
+
requestId: "string",
|
|
854
|
+
success: "boolean"
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
validate() {
|
|
858
|
+
if (this.data && typeof this.data.validate === "function") {
|
|
859
|
+
this.data.validate();
|
|
860
|
+
}
|
|
861
|
+
super.validate();
|
|
862
|
+
}
|
|
863
|
+
constructor(map) {
|
|
864
|
+
super(map);
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
__name(_CreateMcpSessionResponseBody, "CreateMcpSessionResponseBody");
|
|
868
|
+
var CreateMcpSessionResponseBody = _CreateMcpSessionResponseBody;
|
|
869
|
+
|
|
870
|
+
// src/api/models/CreateMcpSessionResponse.ts
|
|
871
|
+
init_cjs_shims();
|
|
872
|
+
|
|
873
|
+
var _CreateMcpSessionResponse = class _CreateMcpSessionResponse extends $dara13.Model {
|
|
874
|
+
static names() {
|
|
875
|
+
return {
|
|
876
|
+
headers: "headers",
|
|
877
|
+
statusCode: "statusCode",
|
|
878
|
+
body: "body"
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
static types() {
|
|
882
|
+
return {
|
|
883
|
+
headers: { "type": "map", "keyType": "string", "valueType": "string" },
|
|
884
|
+
statusCode: "number",
|
|
885
|
+
body: CreateMcpSessionResponseBody
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
validate() {
|
|
889
|
+
if (this.headers) {
|
|
890
|
+
$dara13.Model.validateMap(this.headers);
|
|
891
|
+
}
|
|
892
|
+
if (this.body && typeof this.body.validate === "function") {
|
|
893
|
+
this.body.validate();
|
|
894
|
+
}
|
|
895
|
+
super.validate();
|
|
896
|
+
}
|
|
897
|
+
constructor(map) {
|
|
898
|
+
super(map);
|
|
899
|
+
}
|
|
900
|
+
};
|
|
901
|
+
__name(_CreateMcpSessionResponse, "CreateMcpSessionResponse");
|
|
902
|
+
var CreateMcpSessionResponse = _CreateMcpSessionResponse;
|
|
903
|
+
|
|
904
|
+
// src/api/models/DeleteContextRequest.ts
|
|
905
|
+
init_cjs_shims();
|
|
906
|
+
|
|
907
|
+
var _DeleteContextRequest = class _DeleteContextRequest extends $dara14.Model {
|
|
908
|
+
static names() {
|
|
909
|
+
return {
|
|
910
|
+
authorization: "Authorization",
|
|
911
|
+
id: "Id"
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
static types() {
|
|
915
|
+
return {
|
|
916
|
+
authorization: "string",
|
|
917
|
+
id: "string"
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
validate() {
|
|
921
|
+
super.validate();
|
|
922
|
+
}
|
|
923
|
+
constructor(map) {
|
|
924
|
+
super(map);
|
|
925
|
+
}
|
|
926
|
+
};
|
|
927
|
+
__name(_DeleteContextRequest, "DeleteContextRequest");
|
|
928
|
+
var DeleteContextRequest = _DeleteContextRequest;
|
|
929
|
+
|
|
930
|
+
// src/api/models/DeleteContextResponseBody.ts
|
|
931
|
+
init_cjs_shims();
|
|
932
|
+
|
|
933
|
+
var _DeleteContextResponseBody = class _DeleteContextResponseBody extends $dara15.Model {
|
|
934
|
+
static names() {
|
|
935
|
+
return {
|
|
936
|
+
code: "Code",
|
|
937
|
+
httpStatusCode: "HttpStatusCode",
|
|
938
|
+
message: "Message",
|
|
939
|
+
requestId: "RequestId",
|
|
940
|
+
success: "Success"
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
static types() {
|
|
944
|
+
return {
|
|
945
|
+
code: "string",
|
|
946
|
+
httpStatusCode: "number",
|
|
947
|
+
message: "string",
|
|
948
|
+
requestId: "string",
|
|
949
|
+
success: "boolean"
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
validate() {
|
|
953
|
+
super.validate();
|
|
954
|
+
}
|
|
955
|
+
constructor(map) {
|
|
956
|
+
super(map);
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
__name(_DeleteContextResponseBody, "DeleteContextResponseBody");
|
|
960
|
+
var DeleteContextResponseBody = _DeleteContextResponseBody;
|
|
961
|
+
|
|
962
|
+
// src/api/models/DeleteContextResponse.ts
|
|
963
|
+
init_cjs_shims();
|
|
964
|
+
|
|
965
|
+
var _DeleteContextResponse = class _DeleteContextResponse extends $dara16.Model {
|
|
966
|
+
static names() {
|
|
967
|
+
return {
|
|
968
|
+
headers: "headers",
|
|
969
|
+
statusCode: "statusCode",
|
|
970
|
+
body: "body"
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
static types() {
|
|
974
|
+
return {
|
|
975
|
+
headers: { "type": "map", "keyType": "string", "valueType": "string" },
|
|
976
|
+
statusCode: "number",
|
|
977
|
+
body: DeleteContextResponseBody
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
validate() {
|
|
981
|
+
if (this.headers) {
|
|
982
|
+
$dara16.Model.validateMap(this.headers);
|
|
983
|
+
}
|
|
984
|
+
if (this.body && typeof this.body.validate === "function") {
|
|
985
|
+
this.body.validate();
|
|
986
|
+
}
|
|
987
|
+
super.validate();
|
|
988
|
+
}
|
|
989
|
+
constructor(map) {
|
|
990
|
+
super(map);
|
|
991
|
+
}
|
|
992
|
+
};
|
|
993
|
+
__name(_DeleteContextResponse, "DeleteContextResponse");
|
|
994
|
+
var DeleteContextResponse = _DeleteContextResponse;
|
|
995
|
+
|
|
996
|
+
// src/api/models/GetContextRequest.ts
|
|
997
|
+
init_cjs_shims();
|
|
998
|
+
|
|
999
|
+
var _GetContextRequest = class _GetContextRequest extends $dara17.Model {
|
|
1000
|
+
static names() {
|
|
1001
|
+
return {
|
|
1002
|
+
allowCreate: "AllowCreate",
|
|
1003
|
+
authorization: "Authorization",
|
|
1004
|
+
name: "Name"
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
static types() {
|
|
1008
|
+
return {
|
|
1009
|
+
allowCreate: "boolean",
|
|
1010
|
+
authorization: "string",
|
|
1011
|
+
name: "string"
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
validate() {
|
|
1015
|
+
super.validate();
|
|
1016
|
+
}
|
|
1017
|
+
constructor(map) {
|
|
1018
|
+
super(map);
|
|
1019
|
+
}
|
|
1020
|
+
};
|
|
1021
|
+
__name(_GetContextRequest, "GetContextRequest");
|
|
1022
|
+
var GetContextRequest = _GetContextRequest;
|
|
1023
|
+
|
|
1024
|
+
// src/api/models/GetContextResponseBody.ts
|
|
1025
|
+
init_cjs_shims();
|
|
1026
|
+
|
|
1027
|
+
var _GetContextResponseBody = class _GetContextResponseBody extends $dara18.Model {
|
|
1028
|
+
static names() {
|
|
1029
|
+
return {
|
|
1030
|
+
code: "Code",
|
|
1031
|
+
data: "Data",
|
|
1032
|
+
httpStatusCode: "HttpStatusCode",
|
|
1033
|
+
message: "Message",
|
|
1034
|
+
requestId: "RequestId",
|
|
1035
|
+
success: "Success"
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
static types() {
|
|
1039
|
+
return {
|
|
1040
|
+
code: "string",
|
|
1041
|
+
data: GetContextResponseBodyData,
|
|
1042
|
+
httpStatusCode: "number",
|
|
1043
|
+
message: "string",
|
|
1044
|
+
requestId: "string",
|
|
1045
|
+
success: "boolean"
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
1048
|
+
validate() {
|
|
1049
|
+
if (this.data && typeof this.data.validate === "function") {
|
|
1050
|
+
this.data.validate();
|
|
1051
|
+
}
|
|
1052
|
+
super.validate();
|
|
1053
|
+
}
|
|
1054
|
+
constructor(map) {
|
|
1055
|
+
super(map);
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
__name(_GetContextResponseBody, "GetContextResponseBody");
|
|
1059
|
+
var GetContextResponseBody = _GetContextResponseBody;
|
|
1060
|
+
|
|
1061
|
+
// src/api/models/GetContextResponse.ts
|
|
1062
|
+
init_cjs_shims();
|
|
1063
|
+
|
|
1064
|
+
var _GetContextResponse = class _GetContextResponse extends $dara19.Model {
|
|
1065
|
+
static names() {
|
|
1066
|
+
return {
|
|
1067
|
+
headers: "headers",
|
|
1068
|
+
statusCode: "statusCode",
|
|
1069
|
+
body: "body"
|
|
1070
|
+
};
|
|
1071
|
+
}
|
|
1072
|
+
static types() {
|
|
1073
|
+
return {
|
|
1074
|
+
headers: { "type": "map", "keyType": "string", "valueType": "string" },
|
|
1075
|
+
statusCode: "number",
|
|
1076
|
+
body: GetContextResponseBody
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
validate() {
|
|
1080
|
+
if (this.headers) {
|
|
1081
|
+
$dara19.Model.validateMap(this.headers);
|
|
1082
|
+
}
|
|
1083
|
+
if (this.body && typeof this.body.validate === "function") {
|
|
1084
|
+
this.body.validate();
|
|
1085
|
+
}
|
|
1086
|
+
super.validate();
|
|
1087
|
+
}
|
|
1088
|
+
constructor(map) {
|
|
1089
|
+
super(map);
|
|
1090
|
+
}
|
|
1091
|
+
};
|
|
1092
|
+
__name(_GetContextResponse, "GetContextResponse");
|
|
1093
|
+
var GetContextResponse = _GetContextResponse;
|
|
1094
|
+
|
|
1095
|
+
// src/api/models/GetLabelRequest.ts
|
|
1096
|
+
init_cjs_shims();
|
|
1097
|
+
|
|
1098
|
+
var _GetLabelRequest = class _GetLabelRequest extends $dara20.Model {
|
|
1099
|
+
static names() {
|
|
1100
|
+
return {
|
|
1101
|
+
authorization: "Authorization",
|
|
1102
|
+
maxResults: "MaxResults",
|
|
1103
|
+
nextToken: "NextToken",
|
|
1104
|
+
sessionId: "SessionId"
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1107
|
+
static types() {
|
|
1108
|
+
return {
|
|
1109
|
+
authorization: "string",
|
|
1110
|
+
maxResults: "number",
|
|
1111
|
+
nextToken: "string",
|
|
1112
|
+
sessionId: "string"
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
validate() {
|
|
1116
|
+
super.validate();
|
|
1117
|
+
}
|
|
1118
|
+
constructor(map) {
|
|
1119
|
+
super(map);
|
|
1120
|
+
}
|
|
1121
|
+
};
|
|
1122
|
+
__name(_GetLabelRequest, "GetLabelRequest");
|
|
1123
|
+
var GetLabelRequest = _GetLabelRequest;
|
|
1124
|
+
|
|
1125
|
+
// src/api/models/GetLabelResponseBody.ts
|
|
1126
|
+
init_cjs_shims();
|
|
1127
|
+
|
|
1128
|
+
var _GetLabelResponseBody = class _GetLabelResponseBody extends $dara21.Model {
|
|
1129
|
+
static names() {
|
|
1130
|
+
return {
|
|
1131
|
+
code: "Code",
|
|
1132
|
+
data: "Data",
|
|
1133
|
+
httpStatusCode: "HttpStatusCode",
|
|
1134
|
+
maxResults: "MaxResults",
|
|
1135
|
+
message: "Message",
|
|
1136
|
+
nextToken: "NextToken",
|
|
1137
|
+
requestId: "RequestId",
|
|
1138
|
+
success: "Success",
|
|
1139
|
+
totalCount: "TotalCount"
|
|
1140
|
+
};
|
|
1141
|
+
}
|
|
1142
|
+
static types() {
|
|
1143
|
+
return {
|
|
1144
|
+
code: "string",
|
|
1145
|
+
data: GetLabelResponseBodyData,
|
|
1146
|
+
httpStatusCode: "number",
|
|
1147
|
+
maxResults: "number",
|
|
1148
|
+
message: "string",
|
|
1149
|
+
nextToken: "string",
|
|
1150
|
+
requestId: "string",
|
|
1151
|
+
success: "boolean",
|
|
1152
|
+
totalCount: "number"
|
|
1153
|
+
};
|
|
1154
|
+
}
|
|
1155
|
+
validate() {
|
|
1156
|
+
if (this.data && typeof this.data.validate === "function") {
|
|
1157
|
+
this.data.validate();
|
|
1158
|
+
}
|
|
1159
|
+
super.validate();
|
|
1160
|
+
}
|
|
1161
|
+
constructor(map) {
|
|
1162
|
+
super(map);
|
|
1163
|
+
}
|
|
1164
|
+
};
|
|
1165
|
+
__name(_GetLabelResponseBody, "GetLabelResponseBody");
|
|
1166
|
+
var GetLabelResponseBody = _GetLabelResponseBody;
|
|
1167
|
+
|
|
1168
|
+
// src/api/models/GetLabelResponse.ts
|
|
1169
|
+
init_cjs_shims();
|
|
1170
|
+
|
|
1171
|
+
var _GetLabelResponse = class _GetLabelResponse extends $dara22.Model {
|
|
1172
|
+
static names() {
|
|
1173
|
+
return {
|
|
1174
|
+
headers: "headers",
|
|
1175
|
+
statusCode: "statusCode",
|
|
1176
|
+
body: "body"
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1179
|
+
static types() {
|
|
1180
|
+
return {
|
|
1181
|
+
headers: { "type": "map", "keyType": "string", "valueType": "string" },
|
|
1182
|
+
statusCode: "number",
|
|
1183
|
+
body: GetLabelResponseBody
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1186
|
+
validate() {
|
|
1187
|
+
if (this.headers) {
|
|
1188
|
+
$dara22.Model.validateMap(this.headers);
|
|
1189
|
+
}
|
|
1190
|
+
if (this.body && typeof this.body.validate === "function") {
|
|
1191
|
+
this.body.validate();
|
|
1192
|
+
}
|
|
1193
|
+
super.validate();
|
|
1194
|
+
}
|
|
1195
|
+
constructor(map) {
|
|
1196
|
+
super(map);
|
|
1197
|
+
}
|
|
1198
|
+
};
|
|
1199
|
+
__name(_GetLabelResponse, "GetLabelResponse");
|
|
1200
|
+
var GetLabelResponse = _GetLabelResponse;
|
|
1201
|
+
|
|
1202
|
+
// src/api/models/GetLinkRequest.ts
|
|
1203
|
+
init_cjs_shims();
|
|
1204
|
+
|
|
1205
|
+
var _GetLinkRequest = class _GetLinkRequest extends $dara23.Model {
|
|
1206
|
+
static names() {
|
|
1207
|
+
return {
|
|
1208
|
+
authorization: "Authorization",
|
|
1209
|
+
sessionId: "SessionId"
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
static types() {
|
|
1213
|
+
return {
|
|
1214
|
+
authorization: "string",
|
|
1215
|
+
sessionId: "string"
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1218
|
+
validate() {
|
|
1219
|
+
super.validate();
|
|
1220
|
+
}
|
|
1221
|
+
constructor(map) {
|
|
1222
|
+
super(map);
|
|
1223
|
+
}
|
|
1224
|
+
};
|
|
1225
|
+
__name(_GetLinkRequest, "GetLinkRequest");
|
|
1226
|
+
var GetLinkRequest = _GetLinkRequest;
|
|
1227
|
+
|
|
1228
|
+
// src/api/models/GetLinkResponseBody.ts
|
|
1229
|
+
init_cjs_shims();
|
|
1230
|
+
|
|
1231
|
+
var _GetLinkResponseBody = class _GetLinkResponseBody extends $dara24.Model {
|
|
1232
|
+
static names() {
|
|
1233
|
+
return {
|
|
1234
|
+
code: "Code",
|
|
1235
|
+
data: "Data",
|
|
1236
|
+
httpStatusCode: "HttpStatusCode",
|
|
1237
|
+
message: "Message",
|
|
1238
|
+
requestId: "RequestId",
|
|
1239
|
+
success: "Success"
|
|
1240
|
+
};
|
|
1241
|
+
}
|
|
1242
|
+
static types() {
|
|
1243
|
+
return {
|
|
1244
|
+
code: "string",
|
|
1245
|
+
data: "string",
|
|
1246
|
+
httpStatusCode: "number",
|
|
1247
|
+
message: "string",
|
|
1248
|
+
requestId: "string",
|
|
1249
|
+
success: "boolean"
|
|
1250
|
+
};
|
|
1251
|
+
}
|
|
1252
|
+
validate() {
|
|
1253
|
+
super.validate();
|
|
1254
|
+
}
|
|
1255
|
+
constructor(map) {
|
|
1256
|
+
super(map);
|
|
1257
|
+
}
|
|
1258
|
+
};
|
|
1259
|
+
__name(_GetLinkResponseBody, "GetLinkResponseBody");
|
|
1260
|
+
var GetLinkResponseBody = _GetLinkResponseBody;
|
|
1261
|
+
|
|
1262
|
+
// src/api/models/GetLinkResponse.ts
|
|
1263
|
+
init_cjs_shims();
|
|
1264
|
+
|
|
1265
|
+
var _GetLinkResponse = class _GetLinkResponse extends $dara25.Model {
|
|
1266
|
+
static names() {
|
|
1267
|
+
return {
|
|
1268
|
+
headers: "headers",
|
|
1269
|
+
statusCode: "statusCode",
|
|
1270
|
+
body: "body"
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1273
|
+
static types() {
|
|
1274
|
+
return {
|
|
1275
|
+
headers: { "type": "map", "keyType": "string", "valueType": "string" },
|
|
1276
|
+
statusCode: "number",
|
|
1277
|
+
body: GetLinkResponseBody
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
validate() {
|
|
1281
|
+
if (this.headers) {
|
|
1282
|
+
$dara25.Model.validateMap(this.headers);
|
|
1283
|
+
}
|
|
1284
|
+
if (this.body && typeof this.body.validate === "function") {
|
|
1285
|
+
this.body.validate();
|
|
1286
|
+
}
|
|
1287
|
+
super.validate();
|
|
1288
|
+
}
|
|
1289
|
+
constructor(map) {
|
|
1290
|
+
super(map);
|
|
1291
|
+
}
|
|
1292
|
+
};
|
|
1293
|
+
__name(_GetLinkResponse, "GetLinkResponse");
|
|
1294
|
+
var GetLinkResponse = _GetLinkResponse;
|
|
1295
|
+
|
|
1296
|
+
// src/api/models/GetMcpResourceRequest.ts
|
|
1297
|
+
init_cjs_shims();
|
|
1298
|
+
|
|
1299
|
+
var _GetMcpResourceRequest = class _GetMcpResourceRequest extends $dara26.Model {
|
|
1300
|
+
static names() {
|
|
1301
|
+
return {
|
|
1302
|
+
authorization: "Authorization",
|
|
1303
|
+
sessionId: "SessionId"
|
|
1304
|
+
};
|
|
1305
|
+
}
|
|
1306
|
+
static types() {
|
|
1307
|
+
return {
|
|
1308
|
+
authorization: "string",
|
|
1309
|
+
sessionId: "string"
|
|
1310
|
+
};
|
|
1311
|
+
}
|
|
1312
|
+
validate() {
|
|
1313
|
+
super.validate();
|
|
1314
|
+
}
|
|
1315
|
+
constructor(map) {
|
|
1316
|
+
super(map);
|
|
1317
|
+
}
|
|
1318
|
+
};
|
|
1319
|
+
__name(_GetMcpResourceRequest, "GetMcpResourceRequest");
|
|
1320
|
+
var GetMcpResourceRequest = _GetMcpResourceRequest;
|
|
1321
|
+
|
|
1322
|
+
// src/api/models/GetMcpResourceResponseBody.ts
|
|
1323
|
+
init_cjs_shims();
|
|
1324
|
+
|
|
1325
|
+
var _GetMcpResourceResponseBody = class _GetMcpResourceResponseBody extends $dara27.Model {
|
|
1326
|
+
static names() {
|
|
1327
|
+
return {
|
|
1328
|
+
code: "Code",
|
|
1329
|
+
data: "Data",
|
|
1330
|
+
httpStatusCode: "HttpStatusCode",
|
|
1331
|
+
message: "Message",
|
|
1332
|
+
requestId: "RequestId",
|
|
1333
|
+
success: "Success"
|
|
1334
|
+
};
|
|
1335
|
+
}
|
|
1336
|
+
static types() {
|
|
1337
|
+
return {
|
|
1338
|
+
code: "string",
|
|
1339
|
+
data: GetMcpResourceResponseBodyData,
|
|
1340
|
+
httpStatusCode: "number",
|
|
1341
|
+
message: "string",
|
|
1342
|
+
requestId: "string",
|
|
1343
|
+
success: "boolean"
|
|
1344
|
+
};
|
|
1345
|
+
}
|
|
1346
|
+
validate() {
|
|
1347
|
+
if (this.data && typeof this.data.validate === "function") {
|
|
1348
|
+
this.data.validate();
|
|
1349
|
+
}
|
|
1350
|
+
super.validate();
|
|
1351
|
+
}
|
|
1352
|
+
constructor(map) {
|
|
1353
|
+
super(map);
|
|
1354
|
+
}
|
|
1355
|
+
};
|
|
1356
|
+
__name(_GetMcpResourceResponseBody, "GetMcpResourceResponseBody");
|
|
1357
|
+
var GetMcpResourceResponseBody = _GetMcpResourceResponseBody;
|
|
1358
|
+
|
|
1359
|
+
// src/api/models/GetMcpResourceResponse.ts
|
|
1360
|
+
init_cjs_shims();
|
|
1361
|
+
|
|
1362
|
+
var _GetMcpResourceResponse = class _GetMcpResourceResponse extends $dara28.Model {
|
|
1363
|
+
static names() {
|
|
1364
|
+
return {
|
|
1365
|
+
headers: "headers",
|
|
1366
|
+
statusCode: "statusCode",
|
|
1367
|
+
body: "body"
|
|
1368
|
+
};
|
|
1369
|
+
}
|
|
1370
|
+
static types() {
|
|
1371
|
+
return {
|
|
1372
|
+
headers: { "type": "map", "keyType": "string", "valueType": "string" },
|
|
1373
|
+
statusCode: "number",
|
|
1374
|
+
body: GetMcpResourceResponseBody
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1377
|
+
validate() {
|
|
1378
|
+
if (this.headers) {
|
|
1379
|
+
$dara28.Model.validateMap(this.headers);
|
|
1380
|
+
}
|
|
1381
|
+
if (this.body && typeof this.body.validate === "function") {
|
|
1382
|
+
this.body.validate();
|
|
1383
|
+
}
|
|
1384
|
+
super.validate();
|
|
1385
|
+
}
|
|
1386
|
+
constructor(map) {
|
|
1387
|
+
super(map);
|
|
1388
|
+
}
|
|
1389
|
+
};
|
|
1390
|
+
__name(_GetMcpResourceResponse, "GetMcpResourceResponse");
|
|
1391
|
+
var GetMcpResourceResponse = _GetMcpResourceResponse;
|
|
1392
|
+
|
|
1393
|
+
// src/api/models/ListContextsRequest.ts
|
|
1394
|
+
init_cjs_shims();
|
|
1395
|
+
|
|
1396
|
+
var _ListContextsRequest = class _ListContextsRequest extends $dara29.Model {
|
|
1397
|
+
static names() {
|
|
1398
|
+
return {
|
|
1399
|
+
authorization: "Authorization",
|
|
1400
|
+
maxResults: "MaxResults",
|
|
1401
|
+
nextToken: "NextToken"
|
|
1402
|
+
};
|
|
1403
|
+
}
|
|
1404
|
+
static types() {
|
|
1405
|
+
return {
|
|
1406
|
+
authorization: "string",
|
|
1407
|
+
maxResults: "number",
|
|
1408
|
+
nextToken: "string"
|
|
1409
|
+
};
|
|
1410
|
+
}
|
|
1411
|
+
validate() {
|
|
1412
|
+
super.validate();
|
|
1413
|
+
}
|
|
1414
|
+
constructor(map) {
|
|
1415
|
+
super(map);
|
|
1416
|
+
}
|
|
1417
|
+
};
|
|
1418
|
+
__name(_ListContextsRequest, "ListContextsRequest");
|
|
1419
|
+
var ListContextsRequest = _ListContextsRequest;
|
|
1420
|
+
|
|
1421
|
+
// src/api/models/ListContextsResponseBody.ts
|
|
1422
|
+
init_cjs_shims();
|
|
1423
|
+
|
|
1424
|
+
var _ListContextsResponseBody = class _ListContextsResponseBody extends $dara30.Model {
|
|
1425
|
+
static names() {
|
|
1426
|
+
return {
|
|
1427
|
+
code: "Code",
|
|
1428
|
+
data: "Data",
|
|
1429
|
+
httpStatusCode: "HttpStatusCode",
|
|
1430
|
+
maxResults: "MaxResults",
|
|
1431
|
+
message: "Message",
|
|
1432
|
+
nextToken: "NextToken",
|
|
1433
|
+
requestId: "RequestId",
|
|
1434
|
+
success: "Success",
|
|
1435
|
+
totalCount: "TotalCount"
|
|
1436
|
+
};
|
|
1437
|
+
}
|
|
1438
|
+
static types() {
|
|
1439
|
+
return {
|
|
1440
|
+
code: "string",
|
|
1441
|
+
data: { "type": "array", "itemType": ListContextsResponseBodyData },
|
|
1442
|
+
httpStatusCode: "number",
|
|
1443
|
+
maxResults: "number",
|
|
1444
|
+
message: "string",
|
|
1445
|
+
nextToken: "string",
|
|
1446
|
+
requestId: "string",
|
|
1447
|
+
success: "boolean",
|
|
1448
|
+
totalCount: "number"
|
|
1449
|
+
};
|
|
1450
|
+
}
|
|
1451
|
+
validate() {
|
|
1452
|
+
if (Array.isArray(this.data)) {
|
|
1453
|
+
$dara30.Model.validateArray(this.data);
|
|
1454
|
+
}
|
|
1455
|
+
super.validate();
|
|
1456
|
+
}
|
|
1457
|
+
constructor(map) {
|
|
1458
|
+
super(map);
|
|
1459
|
+
}
|
|
1460
|
+
};
|
|
1461
|
+
__name(_ListContextsResponseBody, "ListContextsResponseBody");
|
|
1462
|
+
var ListContextsResponseBody = _ListContextsResponseBody;
|
|
1463
|
+
|
|
1464
|
+
// src/api/models/ListContextsResponse.ts
|
|
1465
|
+
init_cjs_shims();
|
|
1466
|
+
|
|
1467
|
+
var _ListContextsResponse = class _ListContextsResponse extends $dara31.Model {
|
|
1468
|
+
static names() {
|
|
1469
|
+
return {
|
|
1470
|
+
headers: "headers",
|
|
1471
|
+
statusCode: "statusCode",
|
|
1472
|
+
body: "body"
|
|
1473
|
+
};
|
|
1474
|
+
}
|
|
1475
|
+
static types() {
|
|
1476
|
+
return {
|
|
1477
|
+
headers: { "type": "map", "keyType": "string", "valueType": "string" },
|
|
1478
|
+
statusCode: "number",
|
|
1479
|
+
body: ListContextsResponseBody
|
|
1480
|
+
};
|
|
1481
|
+
}
|
|
1482
|
+
validate() {
|
|
1483
|
+
if (this.headers) {
|
|
1484
|
+
$dara31.Model.validateMap(this.headers);
|
|
1485
|
+
}
|
|
1486
|
+
if (this.body && typeof this.body.validate === "function") {
|
|
1487
|
+
this.body.validate();
|
|
1488
|
+
}
|
|
1489
|
+
super.validate();
|
|
1490
|
+
}
|
|
1491
|
+
constructor(map) {
|
|
1492
|
+
super(map);
|
|
1493
|
+
}
|
|
1494
|
+
};
|
|
1495
|
+
__name(_ListContextsResponse, "ListContextsResponse");
|
|
1496
|
+
var ListContextsResponse = _ListContextsResponse;
|
|
1497
|
+
|
|
1498
|
+
// src/api/models/ListSessionRequest.ts
|
|
1499
|
+
init_cjs_shims();
|
|
1500
|
+
|
|
1501
|
+
var _ListSessionRequest = class _ListSessionRequest extends $dara32.Model {
|
|
1502
|
+
static names() {
|
|
1503
|
+
return {
|
|
1504
|
+
authorization: "Authorization",
|
|
1505
|
+
labels: "Labels",
|
|
1506
|
+
maxResults: "MaxResults",
|
|
1507
|
+
nextToken: "NextToken"
|
|
1508
|
+
};
|
|
1509
|
+
}
|
|
1510
|
+
static types() {
|
|
1511
|
+
return {
|
|
1512
|
+
authorization: "string",
|
|
1513
|
+
labels: "string",
|
|
1514
|
+
maxResults: "number",
|
|
1515
|
+
nextToken: "string"
|
|
1516
|
+
};
|
|
1517
|
+
}
|
|
1518
|
+
validate() {
|
|
1519
|
+
super.validate();
|
|
1520
|
+
}
|
|
1521
|
+
constructor(map) {
|
|
1522
|
+
super(map);
|
|
1523
|
+
}
|
|
1524
|
+
};
|
|
1525
|
+
__name(_ListSessionRequest, "ListSessionRequest");
|
|
1526
|
+
var ListSessionRequest = _ListSessionRequest;
|
|
1527
|
+
|
|
1528
|
+
// src/api/models/ListSessionResponseBody.ts
|
|
1529
|
+
init_cjs_shims();
|
|
1530
|
+
|
|
1531
|
+
var _ListSessionResponseBody = class _ListSessionResponseBody extends $dara33.Model {
|
|
1532
|
+
static names() {
|
|
1533
|
+
return {
|
|
1534
|
+
code: "Code",
|
|
1535
|
+
data: "Data",
|
|
1536
|
+
httpStatusCode: "HttpStatusCode",
|
|
1537
|
+
maxResults: "MaxResults",
|
|
1538
|
+
message: "Message",
|
|
1539
|
+
nextToken: "NextToken",
|
|
1540
|
+
requestId: "RequestId",
|
|
1541
|
+
success: "Success",
|
|
1542
|
+
totalCount: "TotalCount"
|
|
1543
|
+
};
|
|
1544
|
+
}
|
|
1545
|
+
static types() {
|
|
1546
|
+
return {
|
|
1547
|
+
code: "string",
|
|
1548
|
+
data: { "type": "array", "itemType": ListSessionResponseBodyData },
|
|
1549
|
+
httpStatusCode: "number",
|
|
1550
|
+
maxResults: "number",
|
|
1551
|
+
message: "string",
|
|
1552
|
+
nextToken: "string",
|
|
1553
|
+
requestId: "string",
|
|
1554
|
+
success: "boolean",
|
|
1555
|
+
totalCount: "number"
|
|
1556
|
+
};
|
|
1557
|
+
}
|
|
1558
|
+
validate() {
|
|
1559
|
+
if (Array.isArray(this.data)) {
|
|
1560
|
+
$dara33.Model.validateArray(this.data);
|
|
1561
|
+
}
|
|
1562
|
+
super.validate();
|
|
1563
|
+
}
|
|
1564
|
+
constructor(map) {
|
|
1565
|
+
super(map);
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1568
|
+
__name(_ListSessionResponseBody, "ListSessionResponseBody");
|
|
1569
|
+
var ListSessionResponseBody = _ListSessionResponseBody;
|
|
1570
|
+
|
|
1571
|
+
// src/api/models/ListSessionResponse.ts
|
|
1572
|
+
init_cjs_shims();
|
|
1573
|
+
|
|
1574
|
+
var _ListSessionResponse = class _ListSessionResponse extends $dara34.Model {
|
|
1575
|
+
static names() {
|
|
1576
|
+
return {
|
|
1577
|
+
headers: "headers",
|
|
1578
|
+
statusCode: "statusCode",
|
|
1579
|
+
body: "body"
|
|
1580
|
+
};
|
|
1581
|
+
}
|
|
1582
|
+
static types() {
|
|
1583
|
+
return {
|
|
1584
|
+
headers: { "type": "map", "keyType": "string", "valueType": "string" },
|
|
1585
|
+
statusCode: "number",
|
|
1586
|
+
body: ListSessionResponseBody
|
|
1587
|
+
};
|
|
1588
|
+
}
|
|
1589
|
+
validate() {
|
|
1590
|
+
if (this.headers) {
|
|
1591
|
+
$dara34.Model.validateMap(this.headers);
|
|
1592
|
+
}
|
|
1593
|
+
if (this.body && typeof this.body.validate === "function") {
|
|
1594
|
+
this.body.validate();
|
|
1595
|
+
}
|
|
1596
|
+
super.validate();
|
|
1597
|
+
}
|
|
1598
|
+
constructor(map) {
|
|
1599
|
+
super(map);
|
|
1600
|
+
}
|
|
1601
|
+
};
|
|
1602
|
+
__name(_ListSessionResponse, "ListSessionResponse");
|
|
1603
|
+
var ListSessionResponse = _ListSessionResponse;
|
|
1604
|
+
|
|
1605
|
+
// src/api/models/ModifyContextRequest.ts
|
|
1606
|
+
init_cjs_shims();
|
|
1607
|
+
|
|
1608
|
+
var _ModifyContextRequest = class _ModifyContextRequest extends $dara35.Model {
|
|
1609
|
+
static names() {
|
|
1610
|
+
return {
|
|
1611
|
+
authorization: "Authorization",
|
|
1612
|
+
id: "Id",
|
|
1613
|
+
name: "Name"
|
|
1614
|
+
};
|
|
1615
|
+
}
|
|
1616
|
+
static types() {
|
|
1617
|
+
return {
|
|
1618
|
+
authorization: "string",
|
|
1619
|
+
id: "string",
|
|
1620
|
+
name: "string"
|
|
1621
|
+
};
|
|
1622
|
+
}
|
|
1623
|
+
validate() {
|
|
1624
|
+
super.validate();
|
|
1625
|
+
}
|
|
1626
|
+
constructor(map) {
|
|
1627
|
+
super(map);
|
|
1628
|
+
}
|
|
1629
|
+
};
|
|
1630
|
+
__name(_ModifyContextRequest, "ModifyContextRequest");
|
|
1631
|
+
var ModifyContextRequest = _ModifyContextRequest;
|
|
1632
|
+
|
|
1633
|
+
// src/api/models/ModifyContextResponseBody.ts
|
|
1634
|
+
init_cjs_shims();
|
|
1635
|
+
|
|
1636
|
+
var _ModifyContextResponseBody = class _ModifyContextResponseBody extends $dara36.Model {
|
|
1637
|
+
static names() {
|
|
1638
|
+
return {
|
|
1639
|
+
code: "Code",
|
|
1640
|
+
httpStatusCode: "HttpStatusCode",
|
|
1641
|
+
message: "Message",
|
|
1642
|
+
requestId: "RequestId",
|
|
1643
|
+
success: "Success"
|
|
1644
|
+
};
|
|
1645
|
+
}
|
|
1646
|
+
static types() {
|
|
1647
|
+
return {
|
|
1648
|
+
code: "string",
|
|
1649
|
+
httpStatusCode: "number",
|
|
1650
|
+
message: "string",
|
|
1651
|
+
requestId: "string",
|
|
1652
|
+
success: "boolean"
|
|
1653
|
+
};
|
|
1654
|
+
}
|
|
1655
|
+
validate() {
|
|
1656
|
+
super.validate();
|
|
1657
|
+
}
|
|
1658
|
+
constructor(map) {
|
|
1659
|
+
super(map);
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
__name(_ModifyContextResponseBody, "ModifyContextResponseBody");
|
|
1663
|
+
var ModifyContextResponseBody = _ModifyContextResponseBody;
|
|
1664
|
+
|
|
1665
|
+
// src/api/models/ModifyContextResponse.ts
|
|
1666
|
+
init_cjs_shims();
|
|
1667
|
+
|
|
1668
|
+
var _ModifyContextResponse = class _ModifyContextResponse extends $dara37.Model {
|
|
1669
|
+
static names() {
|
|
1670
|
+
return {
|
|
1671
|
+
headers: "headers",
|
|
1672
|
+
statusCode: "statusCode",
|
|
1673
|
+
body: "body"
|
|
1674
|
+
};
|
|
1675
|
+
}
|
|
1676
|
+
static types() {
|
|
1677
|
+
return {
|
|
1678
|
+
headers: { "type": "map", "keyType": "string", "valueType": "string" },
|
|
1679
|
+
statusCode: "number",
|
|
1680
|
+
body: ModifyContextResponseBody
|
|
1681
|
+
};
|
|
1682
|
+
}
|
|
1683
|
+
validate() {
|
|
1684
|
+
if (this.headers) {
|
|
1685
|
+
$dara37.Model.validateMap(this.headers);
|
|
1686
|
+
}
|
|
1687
|
+
if (this.body && typeof this.body.validate === "function") {
|
|
1688
|
+
this.body.validate();
|
|
1689
|
+
}
|
|
1690
|
+
super.validate();
|
|
1691
|
+
}
|
|
1692
|
+
constructor(map) {
|
|
1693
|
+
super(map);
|
|
1694
|
+
}
|
|
1695
|
+
};
|
|
1696
|
+
__name(_ModifyContextResponse, "ModifyContextResponse");
|
|
1697
|
+
var ModifyContextResponse = _ModifyContextResponse;
|
|
1698
|
+
|
|
1699
|
+
// src/api/models/ReleaseMcpSessionRequest.ts
|
|
1700
|
+
init_cjs_shims();
|
|
1701
|
+
|
|
1702
|
+
var _ReleaseMcpSessionRequest = class _ReleaseMcpSessionRequest extends $dara38.Model {
|
|
1703
|
+
static names() {
|
|
1704
|
+
return {
|
|
1705
|
+
authorization: "Authorization",
|
|
1706
|
+
sessionId: "SessionId"
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1709
|
+
static types() {
|
|
1710
|
+
return {
|
|
1711
|
+
authorization: "string",
|
|
1712
|
+
sessionId: "string"
|
|
1713
|
+
};
|
|
1714
|
+
}
|
|
1715
|
+
validate() {
|
|
1716
|
+
super.validate();
|
|
1717
|
+
}
|
|
1718
|
+
constructor(map) {
|
|
1719
|
+
super(map);
|
|
1720
|
+
}
|
|
1721
|
+
};
|
|
1722
|
+
__name(_ReleaseMcpSessionRequest, "ReleaseMcpSessionRequest");
|
|
1723
|
+
var ReleaseMcpSessionRequest = _ReleaseMcpSessionRequest;
|
|
1724
|
+
|
|
1725
|
+
// src/api/models/ReleaseMcpSessionResponseBody.ts
|
|
1726
|
+
init_cjs_shims();
|
|
1727
|
+
|
|
1728
|
+
var _ReleaseMcpSessionResponseBody = class _ReleaseMcpSessionResponseBody extends $dara39.Model {
|
|
1729
|
+
static names() {
|
|
1730
|
+
return {
|
|
1731
|
+
code: "Code",
|
|
1732
|
+
httpStatusCode: "HttpStatusCode",
|
|
1733
|
+
message: "Message",
|
|
1734
|
+
requestId: "RequestId",
|
|
1735
|
+
success: "Success"
|
|
1736
|
+
};
|
|
1737
|
+
}
|
|
1738
|
+
static types() {
|
|
1739
|
+
return {
|
|
1740
|
+
code: "string",
|
|
1741
|
+
httpStatusCode: "number",
|
|
1742
|
+
message: "string",
|
|
1743
|
+
requestId: "string",
|
|
1744
|
+
success: "boolean"
|
|
1745
|
+
};
|
|
1746
|
+
}
|
|
1747
|
+
validate() {
|
|
1748
|
+
super.validate();
|
|
1749
|
+
}
|
|
1750
|
+
constructor(map) {
|
|
1751
|
+
super(map);
|
|
1752
|
+
}
|
|
1753
|
+
};
|
|
1754
|
+
__name(_ReleaseMcpSessionResponseBody, "ReleaseMcpSessionResponseBody");
|
|
1755
|
+
var ReleaseMcpSessionResponseBody = _ReleaseMcpSessionResponseBody;
|
|
1756
|
+
|
|
1757
|
+
// src/api/models/ReleaseMcpSessionResponse.ts
|
|
1758
|
+
init_cjs_shims();
|
|
1759
|
+
|
|
1760
|
+
var _ReleaseMcpSessionResponse = class _ReleaseMcpSessionResponse extends $dara40.Model {
|
|
1761
|
+
static names() {
|
|
1762
|
+
return {
|
|
1763
|
+
headers: "headers",
|
|
1764
|
+
statusCode: "statusCode",
|
|
1765
|
+
body: "body"
|
|
1766
|
+
};
|
|
1767
|
+
}
|
|
1768
|
+
static types() {
|
|
1769
|
+
return {
|
|
1770
|
+
headers: { "type": "map", "keyType": "string", "valueType": "string" },
|
|
1771
|
+
statusCode: "number",
|
|
1772
|
+
body: ReleaseMcpSessionResponseBody
|
|
1773
|
+
};
|
|
1774
|
+
}
|
|
1775
|
+
validate() {
|
|
1776
|
+
if (this.headers) {
|
|
1777
|
+
$dara40.Model.validateMap(this.headers);
|
|
1778
|
+
}
|
|
1779
|
+
if (this.body && typeof this.body.validate === "function") {
|
|
1780
|
+
this.body.validate();
|
|
1781
|
+
}
|
|
1782
|
+
super.validate();
|
|
1783
|
+
}
|
|
1784
|
+
constructor(map) {
|
|
1785
|
+
super(map);
|
|
1786
|
+
}
|
|
1787
|
+
};
|
|
1788
|
+
__name(_ReleaseMcpSessionResponse, "ReleaseMcpSessionResponse");
|
|
1789
|
+
var ReleaseMcpSessionResponse = _ReleaseMcpSessionResponse;
|
|
1790
|
+
|
|
1791
|
+
// src/api/models/SetLabelRequest.ts
|
|
1792
|
+
init_cjs_shims();
|
|
1793
|
+
|
|
1794
|
+
var _SetLabelRequest = class _SetLabelRequest extends $dara41.Model {
|
|
1795
|
+
static names() {
|
|
1796
|
+
return {
|
|
1797
|
+
authorization: "Authorization",
|
|
1798
|
+
labels: "Labels",
|
|
1799
|
+
sessionId: "SessionId"
|
|
1800
|
+
};
|
|
1801
|
+
}
|
|
1802
|
+
static types() {
|
|
1803
|
+
return {
|
|
1804
|
+
authorization: "string",
|
|
1805
|
+
labels: "string",
|
|
1806
|
+
sessionId: "string"
|
|
1807
|
+
};
|
|
1808
|
+
}
|
|
1809
|
+
validate() {
|
|
1810
|
+
super.validate();
|
|
1811
|
+
}
|
|
1812
|
+
constructor(map) {
|
|
1813
|
+
super(map);
|
|
1814
|
+
}
|
|
1815
|
+
};
|
|
1816
|
+
__name(_SetLabelRequest, "SetLabelRequest");
|
|
1817
|
+
var SetLabelRequest = _SetLabelRequest;
|
|
1818
|
+
|
|
1819
|
+
// src/api/models/SetLabelResponseBody.ts
|
|
1820
|
+
init_cjs_shims();
|
|
1821
|
+
|
|
1822
|
+
var _SetLabelResponseBody = class _SetLabelResponseBody extends $dara42.Model {
|
|
1823
|
+
static names() {
|
|
1824
|
+
return {
|
|
1825
|
+
code: "Code",
|
|
1826
|
+
httpStatusCode: "HttpStatusCode",
|
|
1827
|
+
message: "Message",
|
|
1828
|
+
requestId: "RequestId",
|
|
1829
|
+
success: "Success"
|
|
1830
|
+
};
|
|
1831
|
+
}
|
|
1832
|
+
static types() {
|
|
1833
|
+
return {
|
|
1834
|
+
code: "string",
|
|
1835
|
+
httpStatusCode: "number",
|
|
1836
|
+
message: "string",
|
|
1837
|
+
requestId: "string",
|
|
1838
|
+
success: "boolean"
|
|
1839
|
+
};
|
|
1840
|
+
}
|
|
1841
|
+
validate() {
|
|
1842
|
+
super.validate();
|
|
1843
|
+
}
|
|
1844
|
+
constructor(map) {
|
|
1845
|
+
super(map);
|
|
1846
|
+
}
|
|
1847
|
+
};
|
|
1848
|
+
__name(_SetLabelResponseBody, "SetLabelResponseBody");
|
|
1849
|
+
var SetLabelResponseBody = _SetLabelResponseBody;
|
|
1850
|
+
|
|
1851
|
+
// src/api/models/SetLabelResponse.ts
|
|
1852
|
+
init_cjs_shims();
|
|
1853
|
+
|
|
1854
|
+
var _SetLabelResponse = class _SetLabelResponse extends $dara43.Model {
|
|
1855
|
+
static names() {
|
|
1856
|
+
return {
|
|
1857
|
+
headers: "headers",
|
|
1858
|
+
statusCode: "statusCode",
|
|
1859
|
+
body: "body"
|
|
1860
|
+
};
|
|
1861
|
+
}
|
|
1862
|
+
static types() {
|
|
1863
|
+
return {
|
|
1864
|
+
headers: { "type": "map", "keyType": "string", "valueType": "string" },
|
|
1865
|
+
statusCode: "number",
|
|
1866
|
+
body: SetLabelResponseBody
|
|
1867
|
+
};
|
|
1868
|
+
}
|
|
1869
|
+
validate() {
|
|
1870
|
+
if (this.headers) {
|
|
1871
|
+
$dara43.Model.validateMap(this.headers);
|
|
1872
|
+
}
|
|
1873
|
+
if (this.body && typeof this.body.validate === "function") {
|
|
1874
|
+
this.body.validate();
|
|
1875
|
+
}
|
|
1876
|
+
super.validate();
|
|
1877
|
+
}
|
|
1878
|
+
constructor(map) {
|
|
1879
|
+
super(map);
|
|
1880
|
+
}
|
|
1881
|
+
};
|
|
1882
|
+
__name(_SetLabelResponse, "SetLabelResponse");
|
|
1883
|
+
var SetLabelResponse = _SetLabelResponse;
|
|
1884
|
+
|
|
1885
|
+
// src/utils/logger.ts
|
|
1886
|
+
init_cjs_shims();
|
|
1887
|
+
function log(message, ...args) {
|
|
1888
|
+
process.stdout.write(message + "\n");
|
|
1889
|
+
if (args.length > 0) {
|
|
1890
|
+
for (const arg of args) {
|
|
1891
|
+
if (typeof arg === "object") {
|
|
1892
|
+
process.stdout.write(JSON.stringify(arg, null, 2) + "\n");
|
|
1893
|
+
} else {
|
|
1894
|
+
process.stdout.write(String(arg) + "\n");
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
__name(log, "log");
|
|
1900
|
+
function logError(message, error) {
|
|
1901
|
+
process.stderr.write(`ERROR: ${message}
|
|
1902
|
+
`);
|
|
1903
|
+
if (error) {
|
|
1904
|
+
if (error instanceof Error) {
|
|
1905
|
+
process.stderr.write(`${error.message}
|
|
1906
|
+
`);
|
|
1907
|
+
} else if (typeof error === "object") {
|
|
1908
|
+
process.stderr.write(JSON.stringify(error, null, 2) + "\n");
|
|
1909
|
+
} else {
|
|
1910
|
+
process.stderr.write(String(error) + "\n");
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
__name(logError, "logError");
|
|
1915
|
+
|
|
1916
|
+
// src/filesystem/filesystem.ts
|
|
1917
|
+
var DEFAULT_CHUNK_SIZE = 60 * 1024;
|
|
1918
|
+
var FILE_OPERATIONS = {
|
|
1919
|
+
"read_file": true,
|
|
1920
|
+
"write_file": true,
|
|
1921
|
+
"read_multiple_files": true
|
|
1922
|
+
};
|
|
1923
|
+
function isFileOperation(toolName) {
|
|
1924
|
+
return FILE_OPERATIONS[toolName] === true;
|
|
1925
|
+
}
|
|
1926
|
+
__name(isFileOperation, "isFileOperation");
|
|
1927
|
+
function truncateContentForLogging(args) {
|
|
1928
|
+
const truncatedArgs = { ...args };
|
|
1929
|
+
if (typeof truncatedArgs.content === "string") {
|
|
1930
|
+
const contentLength = truncatedArgs.content.length;
|
|
1931
|
+
truncatedArgs.content = `[Content length: ${contentLength} bytes]`;
|
|
1932
|
+
}
|
|
1933
|
+
if (Array.isArray(truncatedArgs.paths) && truncatedArgs.paths.length > 3) {
|
|
1934
|
+
truncatedArgs.paths = `[${truncatedArgs.paths.length} paths, first few: ${truncatedArgs.paths[0]}, ${truncatedArgs.paths[1]}, ${truncatedArgs.paths[2]}, ...]`;
|
|
1935
|
+
}
|
|
1936
|
+
return truncatedArgs;
|
|
1937
|
+
}
|
|
1938
|
+
__name(truncateContentForLogging, "truncateContentForLogging");
|
|
1939
|
+
function parseFileInfo(fileInfoStr) {
|
|
1940
|
+
const result = {
|
|
1941
|
+
name: "",
|
|
1942
|
+
path: "",
|
|
1943
|
+
size: 0,
|
|
1944
|
+
isDirectory: false,
|
|
1945
|
+
modTime: "",
|
|
1946
|
+
mode: ""
|
|
1947
|
+
};
|
|
1948
|
+
const lines = fileInfoStr.split("\n");
|
|
1949
|
+
for (const line of lines) {
|
|
1950
|
+
if (line.includes(":")) {
|
|
1951
|
+
const [key, value] = line.split(":", 2).map((part) => part.trim());
|
|
1952
|
+
switch (key) {
|
|
1953
|
+
case "name":
|
|
1954
|
+
result.name = value;
|
|
1955
|
+
break;
|
|
1956
|
+
case "path":
|
|
1957
|
+
result.path = value;
|
|
1958
|
+
break;
|
|
1959
|
+
case "size":
|
|
1960
|
+
result.size = parseInt(value, 10);
|
|
1961
|
+
break;
|
|
1962
|
+
case "isDirectory":
|
|
1963
|
+
result.isDirectory = value === "true";
|
|
1964
|
+
break;
|
|
1965
|
+
case "modTime":
|
|
1966
|
+
result.modTime = value;
|
|
1967
|
+
break;
|
|
1968
|
+
case "mode":
|
|
1969
|
+
result.mode = value;
|
|
1970
|
+
break;
|
|
1971
|
+
case "owner":
|
|
1972
|
+
result.owner = value;
|
|
1973
|
+
break;
|
|
1974
|
+
case "group":
|
|
1975
|
+
result.group = value;
|
|
1976
|
+
break;
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
return result;
|
|
1981
|
+
}
|
|
1982
|
+
__name(parseFileInfo, "parseFileInfo");
|
|
1983
|
+
function parseDirectoryListing(text) {
|
|
1984
|
+
const result = [];
|
|
1985
|
+
const lines = text.split("\n");
|
|
1986
|
+
for (const line of lines) {
|
|
1987
|
+
const trimmedLine = line.trim();
|
|
1988
|
+
if (trimmedLine === "") {
|
|
1989
|
+
continue;
|
|
1990
|
+
}
|
|
1991
|
+
if (trimmedLine.startsWith("[DIR]")) {
|
|
1992
|
+
result.push({
|
|
1993
|
+
isDirectory: true,
|
|
1994
|
+
name: trimmedLine.replace("[DIR]", "").trim()
|
|
1995
|
+
});
|
|
1996
|
+
} else if (trimmedLine.startsWith("[FILE]")) {
|
|
1997
|
+
result.push({
|
|
1998
|
+
isDirectory: false,
|
|
1999
|
+
name: trimmedLine.replace("[FILE]", "").trim()
|
|
2000
|
+
});
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
return result;
|
|
2004
|
+
}
|
|
2005
|
+
__name(parseDirectoryListing, "parseDirectoryListing");
|
|
2006
|
+
var _FileSystem = class _FileSystem {
|
|
2007
|
+
/**
|
|
2008
|
+
* Initialize a FileSystem object.
|
|
2009
|
+
*
|
|
2010
|
+
* @param session - The Session instance that this FileSystem belongs to.
|
|
2011
|
+
*/
|
|
2012
|
+
constructor(session) {
|
|
2013
|
+
this.session = session;
|
|
2014
|
+
}
|
|
2015
|
+
/**
|
|
2016
|
+
* Helper method to call MCP tools and handle common response processing
|
|
2017
|
+
*
|
|
2018
|
+
* @param toolName - Name of the MCP tool to call
|
|
2019
|
+
* @param args - Arguments to pass to the tool
|
|
2020
|
+
* @param defaultErrorMsg - Default error message if specific error details are not available
|
|
2021
|
+
* @returns A CallMcpToolResult with the response data
|
|
2022
|
+
* @throws APIError if the call fails
|
|
2023
|
+
*/
|
|
2024
|
+
async callMcpTool(toolName, args, defaultErrorMsg) {
|
|
2025
|
+
try {
|
|
2026
|
+
let loggableArgs = args;
|
|
2027
|
+
if (isFileOperation(toolName)) {
|
|
2028
|
+
loggableArgs = truncateContentForLogging(args);
|
|
2029
|
+
}
|
|
2030
|
+
const argsJSON = JSON.stringify(args);
|
|
2031
|
+
const loggableArgsJSON = JSON.stringify(loggableArgs);
|
|
2032
|
+
const callToolRequest = new CallMcpToolRequest({
|
|
2033
|
+
authorization: `Bearer ${this.session.getAPIKey()}`,
|
|
2034
|
+
sessionId: this.session.getSessionId(),
|
|
2035
|
+
name: toolName,
|
|
2036
|
+
args: argsJSON
|
|
2037
|
+
});
|
|
2038
|
+
log(`API Call: CallMcpTool - ${toolName}`);
|
|
2039
|
+
log(`Request: SessionId=${this.session.getSessionId()}, Args=${loggableArgsJSON}`);
|
|
2040
|
+
const response = await this.session.getClient().callMcpTool(callToolRequest);
|
|
2041
|
+
if (isFileOperation(toolName)) {
|
|
2042
|
+
log(`Response from CallMcpTool - ${toolName} - status: ${response.statusCode}`);
|
|
2043
|
+
if (_optionalChain([response, 'access', _ => _.body, 'optionalAccess', _2 => _2.data])) {
|
|
2044
|
+
const data2 = response.body.data;
|
|
2045
|
+
if (data2.isError === true) {
|
|
2046
|
+
log(`Response contains error: ${data2.isError}`);
|
|
2047
|
+
} else {
|
|
2048
|
+
log("Response successful, content length info provided separately");
|
|
2049
|
+
if (Array.isArray(data2.content) && data2.content.length > 0) {
|
|
2050
|
+
let totalSize = 0;
|
|
2051
|
+
for (const item of data2.content) {
|
|
2052
|
+
if (item && typeof item === "object" && item.text && typeof item.text === "string") {
|
|
2053
|
+
totalSize += item.text.length;
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
log(`Content size: ${totalSize} bytes`);
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
} else {
|
|
2061
|
+
const sanitizedBody = { ...response.body };
|
|
2062
|
+
if (sanitizedBody.data && typeof sanitizedBody.data === "object") {
|
|
2063
|
+
const sanitizedData = { ...sanitizedBody.data };
|
|
2064
|
+
if (Array.isArray(sanitizedData.content)) {
|
|
2065
|
+
sanitizedData.content = `[Array with ${sanitizedData.content.length} items]`;
|
|
2066
|
+
}
|
|
2067
|
+
sanitizedBody.data = sanitizedData;
|
|
2068
|
+
}
|
|
2069
|
+
log(`Response from CallMcpTool - ${toolName}:`, sanitizedBody);
|
|
2070
|
+
}
|
|
2071
|
+
if (!_optionalChain([response, 'access', _3 => _3.body, 'optionalAccess', _4 => _4.data])) {
|
|
2072
|
+
throw new Error("Invalid response data format");
|
|
2073
|
+
}
|
|
2074
|
+
const data = response.body.data;
|
|
2075
|
+
const result = {
|
|
2076
|
+
data,
|
|
2077
|
+
statusCode: response.statusCode || 0,
|
|
2078
|
+
isError: false
|
|
2079
|
+
};
|
|
2080
|
+
if (data.isError === true) {
|
|
2081
|
+
result.isError = true;
|
|
2082
|
+
const contentArray = data.content;
|
|
2083
|
+
if (contentArray && contentArray.length > 0) {
|
|
2084
|
+
result.content = contentArray;
|
|
2085
|
+
if (_optionalChain([contentArray, 'access', _5 => _5[0], 'optionalAccess', _6 => _6.text])) {
|
|
2086
|
+
result.errorMsg = contentArray[0].text;
|
|
2087
|
+
throw new Error(contentArray[0].text);
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
throw new Error(defaultErrorMsg);
|
|
2091
|
+
}
|
|
2092
|
+
if (Array.isArray(data.content)) {
|
|
2093
|
+
result.content = data.content;
|
|
2094
|
+
if (result.content.length > 0) {
|
|
2095
|
+
const textParts = [];
|
|
2096
|
+
for (const item of result.content) {
|
|
2097
|
+
if (item && typeof item === "object" && item.text && typeof item.text === "string") {
|
|
2098
|
+
textParts.push(item.text);
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
result.textContent = textParts.join("\n");
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
return result;
|
|
2105
|
+
} catch (error) {
|
|
2106
|
+
logError(`Error calling CallMcpTool - ${toolName}:`, error);
|
|
2107
|
+
throw new APIError(`Failed to call ${toolName}: ${error}`);
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
/**
|
|
2111
|
+
* Creates a new directory at the specified path.
|
|
2112
|
+
*
|
|
2113
|
+
* @param path - Path to the directory to create.
|
|
2114
|
+
* @returns The extracted text content from the API response
|
|
2115
|
+
* @throws APIError if the operation fails.
|
|
2116
|
+
*/
|
|
2117
|
+
async createDirectory(path2) {
|
|
2118
|
+
const args = {
|
|
2119
|
+
path: path2
|
|
2120
|
+
};
|
|
2121
|
+
const result = await this.callMcpTool("create_directory", args, "Failed to create directory");
|
|
2122
|
+
return result.textContent || "";
|
|
2123
|
+
}
|
|
2124
|
+
/**
|
|
2125
|
+
* Edits a file by replacing occurrences of oldText with newText.
|
|
2126
|
+
*
|
|
2127
|
+
* @param path - Path to the file to edit.
|
|
2128
|
+
* @param edits - Array of edit operations, each containing oldText and newText.
|
|
2129
|
+
* @param dryRun - Optional: If true, preview changes without applying them.
|
|
2130
|
+
* @returns The extracted text content from the API response
|
|
2131
|
+
* @throws APIError if the operation fails.
|
|
2132
|
+
*/
|
|
2133
|
+
async editFile(path2, edits, dryRun = false) {
|
|
2134
|
+
const args = {
|
|
2135
|
+
path: path2,
|
|
2136
|
+
edits,
|
|
2137
|
+
dryRun
|
|
2138
|
+
};
|
|
2139
|
+
const result = await this.callMcpTool("edit_file", args, "Failed to edit file");
|
|
2140
|
+
return result.textContent || "";
|
|
2141
|
+
}
|
|
2142
|
+
/**
|
|
2143
|
+
* Gets information about a file or directory.
|
|
2144
|
+
*
|
|
2145
|
+
* @param path - Path to the file or directory to inspect.
|
|
2146
|
+
* @returns The extracted text content from the API response
|
|
2147
|
+
* @throws APIError if the operation fails.
|
|
2148
|
+
*/
|
|
2149
|
+
async getFileInfo(path2) {
|
|
2150
|
+
const args = {
|
|
2151
|
+
path: path2
|
|
2152
|
+
};
|
|
2153
|
+
const result = await this.callMcpTool("get_file_info", args, "Failed to get file info");
|
|
2154
|
+
if (!result.textContent) {
|
|
2155
|
+
throw new APIError("Empty response from get_file_info");
|
|
2156
|
+
}
|
|
2157
|
+
return parseFileInfo(result.textContent);
|
|
2158
|
+
}
|
|
2159
|
+
/**
|
|
2160
|
+
* Lists the contents of a directory.
|
|
2161
|
+
*
|
|
2162
|
+
* @param path - Path to the directory to list.
|
|
2163
|
+
* @returns Array of directory entries with properties like name, isDirectory
|
|
2164
|
+
* @throws APIError if the operation fails.
|
|
2165
|
+
*/
|
|
2166
|
+
async listDirectory(path2) {
|
|
2167
|
+
const args = {
|
|
2168
|
+
path: path2
|
|
2169
|
+
};
|
|
2170
|
+
const result = await this.callMcpTool("list_directory", args, "Failed to list directory");
|
|
2171
|
+
if (!result.textContent) {
|
|
2172
|
+
return [];
|
|
2173
|
+
}
|
|
2174
|
+
return parseDirectoryListing(result.textContent);
|
|
2175
|
+
}
|
|
2176
|
+
/**
|
|
2177
|
+
* Moves a file or directory from source to destination.
|
|
2178
|
+
*
|
|
2179
|
+
* @param source - Path to the source file or directory.
|
|
2180
|
+
* @param destination - Path to the destination file or directory.
|
|
2181
|
+
* @returns The extracted text content from the API response
|
|
2182
|
+
* @throws APIError if the operation fails.
|
|
2183
|
+
*/
|
|
2184
|
+
async moveFile(source, destination) {
|
|
2185
|
+
const args = {
|
|
2186
|
+
source,
|
|
2187
|
+
destination
|
|
2188
|
+
};
|
|
2189
|
+
const result = await this.callMcpTool("move_file", args, "Failed to move file");
|
|
2190
|
+
return result.textContent || "";
|
|
2191
|
+
}
|
|
2192
|
+
/**
|
|
2193
|
+
* Reads the content of a file.
|
|
2194
|
+
*
|
|
2195
|
+
* @param path - Path to the file to read.
|
|
2196
|
+
* @param offset - Optional: Line offset to start reading from.
|
|
2197
|
+
* @param length - Optional: Number of lines to read. If 0, reads the entire file.
|
|
2198
|
+
* @returns The extracted text content from the API response
|
|
2199
|
+
* @throws APIError if the operation fails.
|
|
2200
|
+
*/
|
|
2201
|
+
async readFile(path2, offset = 0, length = 0) {
|
|
2202
|
+
const args = {
|
|
2203
|
+
path: path2
|
|
2204
|
+
};
|
|
2205
|
+
if (offset > 0) {
|
|
2206
|
+
args.offset = offset;
|
|
2207
|
+
}
|
|
2208
|
+
if (length > 0) {
|
|
2209
|
+
args.length = length;
|
|
2210
|
+
}
|
|
2211
|
+
const result = await this.callMcpTool("read_file", args, "Failed to read file");
|
|
2212
|
+
return result.textContent || "";
|
|
2213
|
+
}
|
|
2214
|
+
/**
|
|
2215
|
+
* Reads the content of multiple files.
|
|
2216
|
+
*
|
|
2217
|
+
* @param paths - Array of file paths to read.
|
|
2218
|
+
* @returns The extracted text content from the API response
|
|
2219
|
+
* @throws APIError if the operation fails.
|
|
2220
|
+
*/
|
|
2221
|
+
async readMultipleFiles(paths) {
|
|
2222
|
+
const args = {
|
|
2223
|
+
paths
|
|
2224
|
+
};
|
|
2225
|
+
const result = await this.callMcpTool("read_multiple_files", args, "Failed to read multiple files");
|
|
2226
|
+
if (!result.textContent) {
|
|
2227
|
+
return {};
|
|
2228
|
+
}
|
|
2229
|
+
const fileContents = {};
|
|
2230
|
+
const lines = result.textContent.split("\n");
|
|
2231
|
+
let currentPath = "";
|
|
2232
|
+
let currentContent = [];
|
|
2233
|
+
for (const line of lines) {
|
|
2234
|
+
const colonIndex = line.indexOf(":");
|
|
2235
|
+
if (colonIndex > 0 && currentPath === "" && !line.substring(0, colonIndex).includes(" ")) {
|
|
2236
|
+
const path2 = line.substring(0, colonIndex).trim();
|
|
2237
|
+
currentPath = path2;
|
|
2238
|
+
if (line.length > colonIndex + 1) {
|
|
2239
|
+
const contentStart = line.substring(colonIndex + 1).trim();
|
|
2240
|
+
if (contentStart) {
|
|
2241
|
+
currentContent.push(contentStart);
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
} else if (line === "---") {
|
|
2245
|
+
if (currentPath) {
|
|
2246
|
+
fileContents[currentPath] = currentContent.join("\n");
|
|
2247
|
+
currentPath = "";
|
|
2248
|
+
currentContent = [];
|
|
2249
|
+
}
|
|
2250
|
+
} else if (currentPath) {
|
|
2251
|
+
currentContent.push(line);
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
if (currentPath) {
|
|
2255
|
+
fileContents[currentPath] = currentContent.join("\n");
|
|
2256
|
+
}
|
|
2257
|
+
for (const path2 in fileContents) {
|
|
2258
|
+
fileContents[path2] = fileContents[path2].replace(/\n+$/, "");
|
|
2259
|
+
}
|
|
2260
|
+
return fileContents;
|
|
2261
|
+
}
|
|
2262
|
+
/**
|
|
2263
|
+
* Searches for files in a directory that match a pattern.
|
|
2264
|
+
*
|
|
2265
|
+
* @param path - Path to the directory to search in.
|
|
2266
|
+
* @param pattern - Pattern to search for. Supports glob patterns.
|
|
2267
|
+
* @param excludePatterns - Optional: Array of patterns to exclude.
|
|
2268
|
+
* @returns Array of search results with properties like path
|
|
2269
|
+
* @throws APIError if the operation fails.
|
|
2270
|
+
*/
|
|
2271
|
+
async searchFiles(path2, pattern, excludePatterns = []) {
|
|
2272
|
+
const args = {
|
|
2273
|
+
path: path2,
|
|
2274
|
+
pattern
|
|
2275
|
+
};
|
|
2276
|
+
if (excludePatterns.length > 0) {
|
|
2277
|
+
args.exclude_patterns = excludePatterns;
|
|
2278
|
+
}
|
|
2279
|
+
const result = await this.callMcpTool("search_files", args, "Failed to search files");
|
|
2280
|
+
if (!result.textContent) {
|
|
2281
|
+
return [];
|
|
2282
|
+
}
|
|
2283
|
+
return result.textContent.split("\n").map((line) => line.trim()).filter((line) => line !== "");
|
|
2284
|
+
}
|
|
2285
|
+
/**
|
|
2286
|
+
* Writes content to a file.
|
|
2287
|
+
*
|
|
2288
|
+
* @param path - Path to the file to write.
|
|
2289
|
+
* @param content - Content to write to the file.
|
|
2290
|
+
* @param mode - Optional: Write mode. One of "overwrite", "append", or "create_new". Default is "overwrite".
|
|
2291
|
+
* @returns The extracted text content from the API response
|
|
2292
|
+
* @throws APIError if the operation fails.
|
|
2293
|
+
*/
|
|
2294
|
+
async writeFile(path2, content, mode = "overwrite") {
|
|
2295
|
+
const validModes = ["overwrite", "append", "create_new"];
|
|
2296
|
+
if (!validModes.includes(mode)) {
|
|
2297
|
+
throw new APIError(`Invalid mode: ${mode}. Must be one of ${validModes.join(", ")}`);
|
|
2298
|
+
}
|
|
2299
|
+
const args = {
|
|
2300
|
+
path: path2,
|
|
2301
|
+
content,
|
|
2302
|
+
mode
|
|
2303
|
+
};
|
|
2304
|
+
const result = await this.callMcpTool("write_file", args, "Failed to write file");
|
|
2305
|
+
return result.textContent || "";
|
|
2306
|
+
}
|
|
2307
|
+
/**
|
|
2308
|
+
* Reads a large file in chunks to handle size limitations of the underlying API.
|
|
2309
|
+
* It automatically splits the read operation into multiple requests of chunkSize bytes each.
|
|
2310
|
+
*
|
|
2311
|
+
* @param path - Path to the file to read.
|
|
2312
|
+
* @param chunkSize - Optional: Size of each chunk in bytes. Default is 60KB.
|
|
2313
|
+
* @returns The complete file content as a string
|
|
2314
|
+
* @throws APIError if the operation fails.
|
|
2315
|
+
*/
|
|
2316
|
+
async readLargeFile(path2, chunkSize = DEFAULT_CHUNK_SIZE) {
|
|
2317
|
+
const fileInfo = await this.getFileInfo(path2);
|
|
2318
|
+
const fileSize = fileInfo.size;
|
|
2319
|
+
if (fileSize === 0) {
|
|
2320
|
+
throw new APIError("Couldn't determine file size");
|
|
2321
|
+
}
|
|
2322
|
+
let result = "";
|
|
2323
|
+
let offset = 0;
|
|
2324
|
+
log(`ReadLargeFile: Starting chunked read of ${path2} (total size: ${fileSize} bytes, chunk size: ${chunkSize} bytes)`);
|
|
2325
|
+
let chunkCount = 0;
|
|
2326
|
+
while (offset < fileSize) {
|
|
2327
|
+
let length = chunkSize;
|
|
2328
|
+
if (offset + length > fileSize) {
|
|
2329
|
+
length = fileSize - offset;
|
|
2330
|
+
}
|
|
2331
|
+
log(`ReadLargeFile: Reading chunk ${chunkCount + 1} (${length} bytes at offset ${offset}/${fileSize})`);
|
|
2332
|
+
try {
|
|
2333
|
+
const chunk = await this.readFile(path2, offset, length);
|
|
2334
|
+
result += chunk;
|
|
2335
|
+
offset += length;
|
|
2336
|
+
chunkCount++;
|
|
2337
|
+
} catch (error) {
|
|
2338
|
+
logError(`Error reading chunk at offset ${offset}: ${error}`);
|
|
2339
|
+
throw new APIError(`Error reading chunk at offset ${offset}: ${error}`);
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2342
|
+
log(`ReadLargeFile: Successfully read ${path2} in ${chunkCount} chunks (total: ${fileSize} bytes)`);
|
|
2343
|
+
return result;
|
|
2344
|
+
}
|
|
2345
|
+
/**
|
|
2346
|
+
* Writes a large file in chunks to handle size limitations of the underlying API.
|
|
2347
|
+
* It automatically splits the write operation into multiple requests of chunkSize bytes each.
|
|
2348
|
+
*
|
|
2349
|
+
* @param path - Path to the file to write.
|
|
2350
|
+
* @param content - Content to write to the file.
|
|
2351
|
+
* @param chunkSize - Optional: Size of each chunk in bytes. Default is 60KB.
|
|
2352
|
+
* @returns True if the operation was successful
|
|
2353
|
+
* @throws APIError if the operation fails.
|
|
2354
|
+
*/
|
|
2355
|
+
async writeLargeFile(path2, content, chunkSize = DEFAULT_CHUNK_SIZE) {
|
|
2356
|
+
const contentLen = content.length;
|
|
2357
|
+
log(`WriteLargeFile: Starting chunked write to ${path2} (total size: ${contentLen} bytes, chunk size: ${chunkSize} bytes)`);
|
|
2358
|
+
if (contentLen <= chunkSize) {
|
|
2359
|
+
log(`WriteLargeFile: Content size (${contentLen} bytes) is smaller than chunk size, using normal WriteFile`);
|
|
2360
|
+
await this.writeFile(path2, content, "overwrite");
|
|
2361
|
+
return true;
|
|
2362
|
+
}
|
|
2363
|
+
const firstChunkEnd = Math.min(chunkSize, contentLen);
|
|
2364
|
+
log(`WriteLargeFile: Writing first chunk (0-${firstChunkEnd} bytes) with overwrite mode`);
|
|
2365
|
+
await this.writeFile(path2, content.substring(0, firstChunkEnd), "overwrite");
|
|
2366
|
+
let chunkCount = 1;
|
|
2367
|
+
for (let offset = firstChunkEnd; offset < contentLen; ) {
|
|
2368
|
+
const end = Math.min(offset + chunkSize, contentLen);
|
|
2369
|
+
log(`WriteLargeFile: Writing chunk ${chunkCount + 1} (${offset}-${end} bytes) with append mode`);
|
|
2370
|
+
await this.writeFile(path2, content.substring(offset, end), "append");
|
|
2371
|
+
offset = end;
|
|
2372
|
+
chunkCount++;
|
|
2373
|
+
}
|
|
2374
|
+
log(`WriteLargeFile: Successfully wrote ${path2} in ${chunkCount} chunks (total: ${contentLen} bytes)`);
|
|
2375
|
+
return true;
|
|
2376
|
+
}
|
|
2377
|
+
};
|
|
2378
|
+
__name(_FileSystem, "FileSystem");
|
|
2379
|
+
var FileSystem = _FileSystem;
|
|
2380
|
+
|
|
2381
|
+
// src/command/command.ts
|
|
2382
|
+
init_cjs_shims();
|
|
2383
|
+
var _Command = class _Command {
|
|
2384
|
+
/**
|
|
2385
|
+
* Initialize a Command object.
|
|
2386
|
+
*
|
|
2387
|
+
* @param session - The Session instance that this Command belongs to.
|
|
2388
|
+
*/
|
|
2389
|
+
constructor(session) {
|
|
2390
|
+
this.session = session;
|
|
2391
|
+
}
|
|
2392
|
+
/**
|
|
2393
|
+
* Helper method to call MCP tools and handle common response processing
|
|
2394
|
+
*
|
|
2395
|
+
* @param toolName - Name of the MCP tool to call
|
|
2396
|
+
* @param args - Arguments to pass to the tool
|
|
2397
|
+
* @param defaultErrorMsg - Default error message if specific error details are not available
|
|
2398
|
+
* @returns A CallMcpToolResult with the response data
|
|
2399
|
+
* @throws APIError if the call fails
|
|
2400
|
+
*/
|
|
2401
|
+
async callMcpTool(toolName, args, defaultErrorMsg) {
|
|
2402
|
+
try {
|
|
2403
|
+
const argsJSON = JSON.stringify(args);
|
|
2404
|
+
const callToolRequest = new CallMcpToolRequest({
|
|
2405
|
+
authorization: `Bearer ${this.session.getAPIKey()}`,
|
|
2406
|
+
sessionId: this.session.getSessionId(),
|
|
2407
|
+
name: toolName,
|
|
2408
|
+
args: argsJSON
|
|
2409
|
+
});
|
|
2410
|
+
log(`API Call: CallMcpTool - ${toolName}`);
|
|
2411
|
+
log(`Request: SessionId=${this.session.getSessionId()}, Args=${argsJSON}`);
|
|
2412
|
+
const response = await this.session.getClient().callMcpTool(callToolRequest);
|
|
2413
|
+
log(`Response from CallMcpTool - ${toolName}:`, response.body);
|
|
2414
|
+
if (!_optionalChain([response, 'access', _7 => _7.body, 'optionalAccess', _8 => _8.data])) {
|
|
2415
|
+
throw new Error("Invalid response data format");
|
|
2416
|
+
}
|
|
2417
|
+
const data = response.body.data;
|
|
2418
|
+
const result = {
|
|
2419
|
+
data,
|
|
2420
|
+
statusCode: response.statusCode || 0,
|
|
2421
|
+
isError: false
|
|
2422
|
+
};
|
|
2423
|
+
if (data.isError === true) {
|
|
2424
|
+
result.isError = true;
|
|
2425
|
+
const contentArray = data.content;
|
|
2426
|
+
if (contentArray && contentArray.length > 0) {
|
|
2427
|
+
result.content = contentArray;
|
|
2428
|
+
if (_optionalChain([contentArray, 'access', _9 => _9[0], 'optionalAccess', _10 => _10.text])) {
|
|
2429
|
+
result.errorMsg = contentArray[0].text;
|
|
2430
|
+
throw new Error(contentArray[0].text);
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
throw new Error(defaultErrorMsg);
|
|
2434
|
+
}
|
|
2435
|
+
if (Array.isArray(data.content)) {
|
|
2436
|
+
result.content = data.content;
|
|
2437
|
+
if (result.content.length > 0) {
|
|
2438
|
+
const textParts = [];
|
|
2439
|
+
for (const item of result.content) {
|
|
2440
|
+
if (item && typeof item === "object" && item.text && typeof item.text === "string") {
|
|
2441
|
+
textParts.push(item.text);
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
result.textContent = textParts.join("\n");
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
return result;
|
|
2448
|
+
} catch (error) {
|
|
2449
|
+
logError(`Error calling CallMcpTool - ${toolName}:`, error);
|
|
2450
|
+
throw new APIError(`Failed to call ${toolName}: ${error}`);
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
/**
|
|
2454
|
+
* Helper method to parse JSON string or return a simple object with output
|
|
2455
|
+
*/
|
|
2456
|
+
parseCommandResult(text) {
|
|
2457
|
+
try {
|
|
2458
|
+
return JSON.parse(text);
|
|
2459
|
+
} catch (error) {
|
|
2460
|
+
return { output: text };
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
/**
|
|
2464
|
+
* Execute a command in the cloud environment with a specified timeout.
|
|
2465
|
+
*
|
|
2466
|
+
* @param command - The command to execute.
|
|
2467
|
+
* @param timeoutMs - The timeout for the command execution in milliseconds. Default is 1000ms.
|
|
2468
|
+
* @returns A string containing the command output
|
|
2469
|
+
*/
|
|
2470
|
+
async executeCommand(command, timeoutMs = 1e3) {
|
|
2471
|
+
const args = {
|
|
2472
|
+
command,
|
|
2473
|
+
timeout_ms: timeoutMs
|
|
2474
|
+
};
|
|
2475
|
+
const result = await this.callMcpTool("shell", args, "Failed to execute command");
|
|
2476
|
+
return result.textContent || "";
|
|
2477
|
+
}
|
|
2478
|
+
/**
|
|
2479
|
+
* Helper method to parse JSON string or return a simple object with output
|
|
2480
|
+
*/
|
|
2481
|
+
parseCodeExecutionResult(text) {
|
|
2482
|
+
try {
|
|
2483
|
+
return JSON.parse(text);
|
|
2484
|
+
} catch (error) {
|
|
2485
|
+
return { output: text };
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
/**
|
|
2489
|
+
* Execute code in the specified language with a timeout.
|
|
2490
|
+
*
|
|
2491
|
+
* @param code - The code to execute.
|
|
2492
|
+
* @param language - The programming language of the code. Must be either 'python' or 'javascript'.
|
|
2493
|
+
* @param timeoutS - The timeout for the code execution in seconds. Default is 300s.
|
|
2494
|
+
* @returns A string containing the code execution output
|
|
2495
|
+
* @throws APIError if the code execution fails or if an unsupported language is specified.
|
|
2496
|
+
*/
|
|
2497
|
+
async runCode(code, language, timeoutS = 300) {
|
|
2498
|
+
if (language !== "python" && language !== "javascript") {
|
|
2499
|
+
throw new Error(`Unsupported language: ${language}. Supported languages are 'python' and 'javascript'`);
|
|
2500
|
+
}
|
|
2501
|
+
const args = {
|
|
2502
|
+
code,
|
|
2503
|
+
language,
|
|
2504
|
+
timeout_s: timeoutS
|
|
2505
|
+
};
|
|
2506
|
+
const result = await this.callMcpTool("run_code", args, "Failed to execute code");
|
|
2507
|
+
return result.textContent || "";
|
|
2508
|
+
}
|
|
2509
|
+
};
|
|
2510
|
+
__name(_Command, "Command");
|
|
2511
|
+
var Command = _Command;
|
|
2512
|
+
|
|
2513
|
+
// src/oss/index.ts
|
|
2514
|
+
init_cjs_shims();
|
|
2515
|
+
|
|
2516
|
+
// src/oss/oss.ts
|
|
2517
|
+
init_cjs_shims();
|
|
2518
|
+
|
|
2519
|
+
// src/api/index.ts
|
|
2520
|
+
init_cjs_shims();
|
|
2521
|
+
|
|
2522
|
+
// src/api/client.ts
|
|
2523
|
+
init_cjs_shims();
|
|
2524
|
+
|
|
2525
|
+
var _openapicore = require('@alicloud/openapi-core'); var OpenApiDefault = _interopRequireWildcard(_openapicore);
|
|
2526
|
+
|
|
2527
|
+
var OpenApi = OpenApiDefault.default || OpenApiDefault;
|
|
2528
|
+
var _Client = class _Client extends OpenApi {
|
|
2529
|
+
constructor(config) {
|
|
2530
|
+
super(config);
|
|
2531
|
+
this._signatureAlgorithm = "v2";
|
|
2532
|
+
this._endpointRule = "";
|
|
2533
|
+
this.checkConfig(config);
|
|
2534
|
+
this._endpoint = this.getEndpoint("wuyingai", this._regionId, this._endpointRule, this._network, this._suffix, this._endpointMap, this._endpoint);
|
|
2535
|
+
}
|
|
2536
|
+
getEndpoint(productId, regionId, endpointRule, network, suffix, endpointMap, endpoint) {
|
|
2537
|
+
if (!$dara44.isNull(endpoint)) {
|
|
2538
|
+
return endpoint;
|
|
2539
|
+
}
|
|
2540
|
+
if (!$dara44.isNull(endpointMap) && !$dara44.isNull(endpointMap[regionId])) {
|
|
2541
|
+
return endpointMap[regionId];
|
|
2542
|
+
}
|
|
2543
|
+
return _openapicore.OpenApiUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
|
|
2544
|
+
}
|
|
2545
|
+
/**
|
|
2546
|
+
* 调用mcp工具
|
|
2547
|
+
*
|
|
2548
|
+
* @param request - CallMcpToolRequest
|
|
2549
|
+
* @param runtime - runtime options for this request RuntimeOptions
|
|
2550
|
+
* @returns CallMcpToolResponse
|
|
2551
|
+
*/
|
|
2552
|
+
async callMcpToolWithOptions(request, runtime) {
|
|
2553
|
+
request.validate();
|
|
2554
|
+
let body = {};
|
|
2555
|
+
if (!$dara44.isNull(request.args)) {
|
|
2556
|
+
body["Args"] = request.args;
|
|
2557
|
+
}
|
|
2558
|
+
if (!$dara44.isNull(request.authorization)) {
|
|
2559
|
+
body["Authorization"] = request.authorization;
|
|
2560
|
+
}
|
|
2561
|
+
if (!$dara44.isNull(request.externalUserId)) {
|
|
2562
|
+
body["ExternalUserId"] = request.externalUserId;
|
|
2563
|
+
}
|
|
2564
|
+
if (!$dara44.isNull(request.imageId)) {
|
|
2565
|
+
body["ImageId"] = request.imageId;
|
|
2566
|
+
}
|
|
2567
|
+
if (!$dara44.isNull(request.name)) {
|
|
2568
|
+
body["Name"] = request.name;
|
|
2569
|
+
}
|
|
2570
|
+
if (!$dara44.isNull(request.server)) {
|
|
2571
|
+
body["Server"] = request.server;
|
|
2572
|
+
}
|
|
2573
|
+
if (!$dara44.isNull(request.sessionId)) {
|
|
2574
|
+
body["SessionId"] = request.sessionId;
|
|
2575
|
+
}
|
|
2576
|
+
if (!$dara44.isNull(request.tool)) {
|
|
2577
|
+
body["Tool"] = request.tool;
|
|
2578
|
+
}
|
|
2579
|
+
let req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
2580
|
+
body: _openapicore.OpenApiUtil.parseToMap(body)
|
|
2581
|
+
});
|
|
2582
|
+
let params = new _openapicore.$OpenApiUtil.Params({
|
|
2583
|
+
action: "CallMcpTool",
|
|
2584
|
+
version: "2025-05-06",
|
|
2585
|
+
protocol: "HTTPS",
|
|
2586
|
+
pathname: "/",
|
|
2587
|
+
method: "POST",
|
|
2588
|
+
authType: "Anonymous",
|
|
2589
|
+
style: "RPC",
|
|
2590
|
+
reqBodyType: "formData",
|
|
2591
|
+
bodyType: "json"
|
|
2592
|
+
});
|
|
2593
|
+
return $dara44.cast(await this.callApi(params, req, runtime), new CallMcpToolResponse({}));
|
|
2594
|
+
}
|
|
2595
|
+
/**
|
|
2596
|
+
* 调用mcp工具
|
|
2597
|
+
*
|
|
2598
|
+
* @param request - CallMcpToolRequest
|
|
2599
|
+
* @returns CallMcpToolResponse
|
|
2600
|
+
*/
|
|
2601
|
+
async callMcpTool(request) {
|
|
2602
|
+
let runtime = new $dara44.RuntimeOptions({});
|
|
2603
|
+
return await this.callMcpToolWithOptions(request, runtime);
|
|
2604
|
+
}
|
|
2605
|
+
/**
|
|
2606
|
+
* 创建 mcp session
|
|
2607
|
+
*
|
|
2608
|
+
* @param request - CreateMcpSessionRequest
|
|
2609
|
+
* @param runtime - runtime options for this request RuntimeOptions
|
|
2610
|
+
* @returns CreateMcpSessionResponse
|
|
2611
|
+
*/
|
|
2612
|
+
async createMcpSessionWithOptions(request, runtime) {
|
|
2613
|
+
request.validate();
|
|
2614
|
+
let body = {};
|
|
2615
|
+
if (!$dara44.isNull(request.authorization)) {
|
|
2616
|
+
body["Authorization"] = request.authorization;
|
|
2617
|
+
}
|
|
2618
|
+
if (!$dara44.isNull(request.contextId)) {
|
|
2619
|
+
body["ContextId"] = request.contextId;
|
|
2620
|
+
}
|
|
2621
|
+
if (!$dara44.isNull(request.externalUserId)) {
|
|
2622
|
+
body["ExternalUserId"] = request.externalUserId;
|
|
2623
|
+
}
|
|
2624
|
+
if (!$dara44.isNull(request.imageId)) {
|
|
2625
|
+
body["ImageId"] = request.imageId;
|
|
2626
|
+
}
|
|
2627
|
+
if (!$dara44.isNull(request.labels)) {
|
|
2628
|
+
body["Labels"] = request.labels;
|
|
2629
|
+
}
|
|
2630
|
+
if (!$dara44.isNull(request.sessionId)) {
|
|
2631
|
+
body["SessionId"] = request.sessionId;
|
|
2632
|
+
}
|
|
2633
|
+
if (!$dara44.isNull(request.imageId)) {
|
|
2634
|
+
body["ImageId"] = request.imageId;
|
|
2635
|
+
}
|
|
2636
|
+
let req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
2637
|
+
body: _openapicore.OpenApiUtil.parseToMap(body)
|
|
2638
|
+
});
|
|
2639
|
+
let params = new _openapicore.$OpenApiUtil.Params({
|
|
2640
|
+
action: "CreateMcpSession",
|
|
2641
|
+
version: "2025-05-06",
|
|
2642
|
+
protocol: "HTTPS",
|
|
2643
|
+
pathname: "/",
|
|
2644
|
+
method: "POST",
|
|
2645
|
+
authType: "Anonymous",
|
|
2646
|
+
style: "RPC",
|
|
2647
|
+
reqBodyType: "formData",
|
|
2648
|
+
bodyType: "json"
|
|
2649
|
+
});
|
|
2650
|
+
return $dara44.cast(await this.callApi(params, req, runtime), new CreateMcpSessionResponse({}));
|
|
2651
|
+
}
|
|
2652
|
+
/**
|
|
2653
|
+
* 创建 mcp session
|
|
2654
|
+
*
|
|
2655
|
+
* @param request - CreateMcpSessionRequest
|
|
2656
|
+
* @returns CreateMcpSessionResponse
|
|
2657
|
+
*/
|
|
2658
|
+
async createMcpSession(request) {
|
|
2659
|
+
let runtime = new $dara44.RuntimeOptions({});
|
|
2660
|
+
return await this.createMcpSessionWithOptions(request, runtime);
|
|
2661
|
+
}
|
|
2662
|
+
/**
|
|
2663
|
+
* 删除持久化上下文
|
|
2664
|
+
*
|
|
2665
|
+
* @param request - DeleteContextRequest
|
|
2666
|
+
* @param runtime - runtime options for this request RuntimeOptions
|
|
2667
|
+
* @returns DeleteContextResponse
|
|
2668
|
+
*/
|
|
2669
|
+
async deleteContextWithOptions(request, runtime) {
|
|
2670
|
+
request.validate();
|
|
2671
|
+
let body = {};
|
|
2672
|
+
if (!$dara44.isNull(request.authorization)) {
|
|
2673
|
+
body["Authorization"] = request.authorization;
|
|
2674
|
+
}
|
|
2675
|
+
if (!$dara44.isNull(request.id)) {
|
|
2676
|
+
body["Id"] = request.id;
|
|
2677
|
+
}
|
|
2678
|
+
let req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
2679
|
+
body: _openapicore.OpenApiUtil.parseToMap(body)
|
|
2680
|
+
});
|
|
2681
|
+
let params = new _openapicore.$OpenApiUtil.Params({
|
|
2682
|
+
action: "DeleteContext",
|
|
2683
|
+
version: "2025-05-06",
|
|
2684
|
+
protocol: "HTTPS",
|
|
2685
|
+
pathname: "/",
|
|
2686
|
+
method: "POST",
|
|
2687
|
+
authType: "Anonymous",
|
|
2688
|
+
style: "RPC",
|
|
2689
|
+
reqBodyType: "formData",
|
|
2690
|
+
bodyType: "json"
|
|
2691
|
+
});
|
|
2692
|
+
return $dara44.cast(await this.callApi(params, req, runtime), new DeleteContextResponse({}));
|
|
2693
|
+
}
|
|
2694
|
+
/**
|
|
2695
|
+
* 删除持久化上下文
|
|
2696
|
+
*
|
|
2697
|
+
* @param request - DeleteContextRequest
|
|
2698
|
+
* @returns DeleteContextResponse
|
|
2699
|
+
*/
|
|
2700
|
+
async deleteContext(request) {
|
|
2701
|
+
let runtime = new $dara44.RuntimeOptions({});
|
|
2702
|
+
return await this.deleteContextWithOptions(request, runtime);
|
|
2703
|
+
}
|
|
2704
|
+
/**
|
|
2705
|
+
* 获取上下文
|
|
2706
|
+
*
|
|
2707
|
+
* @param request - GetContextRequest
|
|
2708
|
+
* @param runtime - runtime options for this request RuntimeOptions
|
|
2709
|
+
* @returns GetContextResponse
|
|
2710
|
+
*/
|
|
2711
|
+
async getContextWithOptions(request, runtime) {
|
|
2712
|
+
request.validate();
|
|
2713
|
+
let body = {};
|
|
2714
|
+
if (!$dara44.isNull(request.allowCreate)) {
|
|
2715
|
+
body["AllowCreate"] = request.allowCreate;
|
|
2716
|
+
}
|
|
2717
|
+
if (!$dara44.isNull(request.authorization)) {
|
|
2718
|
+
body["Authorization"] = request.authorization;
|
|
2719
|
+
}
|
|
2720
|
+
if (!$dara44.isNull(request.name)) {
|
|
2721
|
+
body["Name"] = request.name;
|
|
2722
|
+
}
|
|
2723
|
+
let req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
2724
|
+
body: _openapicore.OpenApiUtil.parseToMap(body)
|
|
2725
|
+
});
|
|
2726
|
+
let params = new _openapicore.$OpenApiUtil.Params({
|
|
2727
|
+
action: "GetContext",
|
|
2728
|
+
version: "2025-05-06",
|
|
2729
|
+
protocol: "HTTPS",
|
|
2730
|
+
pathname: "/",
|
|
2731
|
+
method: "POST",
|
|
2732
|
+
authType: "Anonymous",
|
|
2733
|
+
style: "RPC",
|
|
2734
|
+
reqBodyType: "formData",
|
|
2735
|
+
bodyType: "json"
|
|
2736
|
+
});
|
|
2737
|
+
return $dara44.cast(await this.callApi(params, req, runtime), new GetContextResponse({}));
|
|
2738
|
+
}
|
|
2739
|
+
/**
|
|
2740
|
+
* 获取上下文
|
|
2741
|
+
*
|
|
2742
|
+
* @param request - GetContextRequest
|
|
2743
|
+
* @returns GetContextResponse
|
|
2744
|
+
*/
|
|
2745
|
+
async getContext(request) {
|
|
2746
|
+
let runtime = new $dara44.RuntimeOptions({});
|
|
2747
|
+
return await this.getContextWithOptions(request, runtime);
|
|
2748
|
+
}
|
|
2749
|
+
/**
|
|
2750
|
+
* 获取标签
|
|
2751
|
+
*
|
|
2752
|
+
* @param request - GetLabelRequest
|
|
2753
|
+
* @param runtime - runtime options for this request RuntimeOptions
|
|
2754
|
+
* @returns GetLabelResponse
|
|
2755
|
+
*/
|
|
2756
|
+
async getLabelWithOptions(request, runtime) {
|
|
2757
|
+
request.validate();
|
|
2758
|
+
let body = {};
|
|
2759
|
+
if (!$dara44.isNull(request.authorization)) {
|
|
2760
|
+
body["Authorization"] = request.authorization;
|
|
2761
|
+
}
|
|
2762
|
+
if (!$dara44.isNull(request.maxResults)) {
|
|
2763
|
+
body["MaxResults"] = request.maxResults;
|
|
2764
|
+
}
|
|
2765
|
+
if (!$dara44.isNull(request.nextToken)) {
|
|
2766
|
+
body["NextToken"] = request.nextToken;
|
|
2767
|
+
}
|
|
2768
|
+
if (!$dara44.isNull(request.sessionId)) {
|
|
2769
|
+
body["SessionId"] = request.sessionId;
|
|
2770
|
+
}
|
|
2771
|
+
let req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
2772
|
+
body: _openapicore.OpenApiUtil.parseToMap(body)
|
|
2773
|
+
});
|
|
2774
|
+
let params = new _openapicore.$OpenApiUtil.Params({
|
|
2775
|
+
action: "GetLabel",
|
|
2776
|
+
version: "2025-05-06",
|
|
2777
|
+
protocol: "HTTPS",
|
|
2778
|
+
pathname: "/",
|
|
2779
|
+
method: "POST",
|
|
2780
|
+
authType: "Anonymous",
|
|
2781
|
+
style: "RPC",
|
|
2782
|
+
reqBodyType: "formData",
|
|
2783
|
+
bodyType: "json"
|
|
2784
|
+
});
|
|
2785
|
+
return $dara44.cast(await this.callApi(params, req, runtime), new GetLabelResponse({}));
|
|
2786
|
+
}
|
|
2787
|
+
/**
|
|
2788
|
+
* 获取标签
|
|
2789
|
+
*
|
|
2790
|
+
* @param request - GetLabelRequest
|
|
2791
|
+
* @returns GetLabelResponse
|
|
2792
|
+
*/
|
|
2793
|
+
async getLabel(request) {
|
|
2794
|
+
let runtime = new $dara44.RuntimeOptions({});
|
|
2795
|
+
return await this.getLabelWithOptions(request, runtime);
|
|
2796
|
+
}
|
|
2797
|
+
/**
|
|
2798
|
+
* 获取特定端口的转发链接
|
|
2799
|
+
*
|
|
2800
|
+
* @param request - GetLinkRequest
|
|
2801
|
+
* @param runtime - runtime options for this request RuntimeOptions
|
|
2802
|
+
* @returns GetLinkResponse
|
|
2803
|
+
*/
|
|
2804
|
+
async getLinkWithOptions(request, runtime) {
|
|
2805
|
+
request.validate();
|
|
2806
|
+
let body = {};
|
|
2807
|
+
if (!$dara44.isNull(request.authorization)) {
|
|
2808
|
+
body["Authorization"] = request.authorization;
|
|
2809
|
+
}
|
|
2810
|
+
if (!$dara44.isNull(request.sessionId)) {
|
|
2811
|
+
body["SessionId"] = request.sessionId;
|
|
2812
|
+
}
|
|
2813
|
+
let req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
2814
|
+
body: _openapicore.OpenApiUtil.parseToMap(body)
|
|
2815
|
+
});
|
|
2816
|
+
let params = new _openapicore.$OpenApiUtil.Params({
|
|
2817
|
+
action: "GetLink",
|
|
2818
|
+
version: "2025-05-06",
|
|
2819
|
+
protocol: "HTTPS",
|
|
2820
|
+
pathname: "/",
|
|
2821
|
+
method: "POST",
|
|
2822
|
+
authType: "Anonymous",
|
|
2823
|
+
style: "RPC",
|
|
2824
|
+
reqBodyType: "formData",
|
|
2825
|
+
bodyType: "json"
|
|
2826
|
+
});
|
|
2827
|
+
return $dara44.cast(await this.callApi(params, req, runtime), new GetLinkResponse({}));
|
|
2828
|
+
}
|
|
2829
|
+
/**
|
|
2830
|
+
* 获取特定端口的转发链接
|
|
2831
|
+
*
|
|
2832
|
+
* @param request - GetLinkRequest
|
|
2833
|
+
* @returns GetLinkResponse
|
|
2834
|
+
*/
|
|
2835
|
+
async getLink(request) {
|
|
2836
|
+
let runtime = new $dara44.RuntimeOptions({});
|
|
2837
|
+
return await this.getLinkWithOptions(request, runtime);
|
|
2838
|
+
}
|
|
2839
|
+
/**
|
|
2840
|
+
* 获取mcp资源信息
|
|
2841
|
+
*
|
|
2842
|
+
* @param request - GetMcpResourceRequest
|
|
2843
|
+
* @param runtime - runtime options for this request RuntimeOptions
|
|
2844
|
+
* @returns GetMcpResourceResponse
|
|
2845
|
+
*/
|
|
2846
|
+
async getMcpResourceWithOptions(request, runtime) {
|
|
2847
|
+
request.validate();
|
|
2848
|
+
let body = {};
|
|
2849
|
+
if (!$dara44.isNull(request.authorization)) {
|
|
2850
|
+
body["Authorization"] = request.authorization;
|
|
2851
|
+
}
|
|
2852
|
+
if (!$dara44.isNull(request.sessionId)) {
|
|
2853
|
+
body["SessionId"] = request.sessionId;
|
|
2854
|
+
}
|
|
2855
|
+
let req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
2856
|
+
body: _openapicore.OpenApiUtil.parseToMap(body)
|
|
2857
|
+
});
|
|
2858
|
+
let params = new _openapicore.$OpenApiUtil.Params({
|
|
2859
|
+
action: "GetMcpResource",
|
|
2860
|
+
version: "2025-05-06",
|
|
2861
|
+
protocol: "HTTPS",
|
|
2862
|
+
pathname: "/",
|
|
2863
|
+
method: "POST",
|
|
2864
|
+
authType: "Anonymous",
|
|
2865
|
+
style: "RPC",
|
|
2866
|
+
reqBodyType: "formData",
|
|
2867
|
+
bodyType: "json"
|
|
2868
|
+
});
|
|
2869
|
+
return $dara44.cast(await this.callApi(params, req, runtime), new GetMcpResourceResponse({}));
|
|
2870
|
+
}
|
|
2871
|
+
/**
|
|
2872
|
+
* 获取mcp资源信息
|
|
2873
|
+
*
|
|
2874
|
+
* @param request - GetMcpResourceRequest
|
|
2875
|
+
* @returns GetMcpResourceResponse
|
|
2876
|
+
*/
|
|
2877
|
+
async getMcpResource(request) {
|
|
2878
|
+
let runtime = new $dara44.RuntimeOptions({});
|
|
2879
|
+
return await this.getMcpResourceWithOptions(request, runtime);
|
|
2880
|
+
}
|
|
2881
|
+
/**
|
|
2882
|
+
* 获取上下文列表
|
|
2883
|
+
*
|
|
2884
|
+
* @param request - ListContextsRequest
|
|
2885
|
+
* @param runtime - runtime options for this request RuntimeOptions
|
|
2886
|
+
* @returns ListContextsResponse
|
|
2887
|
+
*/
|
|
2888
|
+
async listContextsWithOptions(request, runtime) {
|
|
2889
|
+
request.validate();
|
|
2890
|
+
let body = {};
|
|
2891
|
+
if (!$dara44.isNull(request.authorization)) {
|
|
2892
|
+
body["Authorization"] = request.authorization;
|
|
2893
|
+
}
|
|
2894
|
+
if (!$dara44.isNull(request.maxResults)) {
|
|
2895
|
+
body["MaxResults"] = request.maxResults;
|
|
2896
|
+
}
|
|
2897
|
+
if (!$dara44.isNull(request.nextToken)) {
|
|
2898
|
+
body["NextToken"] = request.nextToken;
|
|
2899
|
+
}
|
|
2900
|
+
let req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
2901
|
+
body: _openapicore.OpenApiUtil.parseToMap(body)
|
|
2902
|
+
});
|
|
2903
|
+
let params = new _openapicore.$OpenApiUtil.Params({
|
|
2904
|
+
action: "ListContexts",
|
|
2905
|
+
version: "2025-05-06",
|
|
2906
|
+
protocol: "HTTPS",
|
|
2907
|
+
pathname: "/",
|
|
2908
|
+
method: "POST",
|
|
2909
|
+
authType: "Anonymous",
|
|
2910
|
+
style: "RPC",
|
|
2911
|
+
reqBodyType: "formData",
|
|
2912
|
+
bodyType: "json"
|
|
2913
|
+
});
|
|
2914
|
+
return $dara44.cast(await this.callApi(params, req, runtime), new ListContextsResponse({}));
|
|
2915
|
+
}
|
|
2916
|
+
/**
|
|
2917
|
+
* 获取上下文列表
|
|
2918
|
+
*
|
|
2919
|
+
* @param request - ListContextsRequest
|
|
2920
|
+
* @returns ListContextsResponse
|
|
2921
|
+
*/
|
|
2922
|
+
async listContexts(request) {
|
|
2923
|
+
let runtime = new $dara44.RuntimeOptions({});
|
|
2924
|
+
return await this.listContextsWithOptions(request, runtime);
|
|
2925
|
+
}
|
|
2926
|
+
/**
|
|
2927
|
+
* 根据Lable查询Session列表
|
|
2928
|
+
*
|
|
2929
|
+
* @param request - ListSessionRequest
|
|
2930
|
+
* @param runtime - runtime options for this request RuntimeOptions
|
|
2931
|
+
* @returns ListSessionResponse
|
|
2932
|
+
*/
|
|
2933
|
+
async listSessionWithOptions(request, runtime) {
|
|
2934
|
+
request.validate();
|
|
2935
|
+
let body = {};
|
|
2936
|
+
if (!$dara44.isNull(request.authorization)) {
|
|
2937
|
+
body["Authorization"] = request.authorization;
|
|
2938
|
+
}
|
|
2939
|
+
if (!$dara44.isNull(request.labels)) {
|
|
2940
|
+
body["Labels"] = request.labels;
|
|
2941
|
+
}
|
|
2942
|
+
if (!$dara44.isNull(request.maxResults)) {
|
|
2943
|
+
body["MaxResults"] = request.maxResults;
|
|
2944
|
+
}
|
|
2945
|
+
if (!$dara44.isNull(request.nextToken)) {
|
|
2946
|
+
body["NextToken"] = request.nextToken;
|
|
2947
|
+
}
|
|
2948
|
+
let req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
2949
|
+
body: _openapicore.OpenApiUtil.parseToMap(body)
|
|
2950
|
+
});
|
|
2951
|
+
let params = new _openapicore.$OpenApiUtil.Params({
|
|
2952
|
+
action: "ListSession",
|
|
2953
|
+
version: "2025-05-06",
|
|
2954
|
+
protocol: "HTTPS",
|
|
2955
|
+
pathname: "/",
|
|
2956
|
+
method: "POST",
|
|
2957
|
+
authType: "Anonymous",
|
|
2958
|
+
style: "RPC",
|
|
2959
|
+
reqBodyType: "formData",
|
|
2960
|
+
bodyType: "json"
|
|
2961
|
+
});
|
|
2962
|
+
return $dara44.cast(await this.callApi(params, req, runtime), new ListSessionResponse({}));
|
|
2963
|
+
}
|
|
2964
|
+
/**
|
|
2965
|
+
* 根据Lable查询Session列表
|
|
2966
|
+
*
|
|
2967
|
+
* @param request - ListSessionRequest
|
|
2968
|
+
* @returns ListSessionResponse
|
|
2969
|
+
*/
|
|
2970
|
+
async listSession(request) {
|
|
2971
|
+
let runtime = new $dara44.RuntimeOptions({});
|
|
2972
|
+
return await this.listSessionWithOptions(request, runtime);
|
|
2973
|
+
}
|
|
2974
|
+
/**
|
|
2975
|
+
* 修改上下文
|
|
2976
|
+
*
|
|
2977
|
+
* @param request - ModifyContextRequest
|
|
2978
|
+
* @param runtime - runtime options for this request RuntimeOptions
|
|
2979
|
+
* @returns ModifyContextResponse
|
|
2980
|
+
*/
|
|
2981
|
+
async modifyContextWithOptions(request, runtime) {
|
|
2982
|
+
request.validate();
|
|
2983
|
+
let body = {};
|
|
2984
|
+
if (!$dara44.isNull(request.authorization)) {
|
|
2985
|
+
body["Authorization"] = request.authorization;
|
|
2986
|
+
}
|
|
2987
|
+
if (!$dara44.isNull(request.id)) {
|
|
2988
|
+
body["Id"] = request.id;
|
|
2989
|
+
}
|
|
2990
|
+
if (!$dara44.isNull(request.name)) {
|
|
2991
|
+
body["Name"] = request.name;
|
|
2992
|
+
}
|
|
2993
|
+
let req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
2994
|
+
body: _openapicore.OpenApiUtil.parseToMap(body)
|
|
2995
|
+
});
|
|
2996
|
+
let params = new _openapicore.$OpenApiUtil.Params({
|
|
2997
|
+
action: "ModifyContext",
|
|
2998
|
+
version: "2025-05-06",
|
|
2999
|
+
protocol: "HTTPS",
|
|
3000
|
+
pathname: "/",
|
|
3001
|
+
method: "POST",
|
|
3002
|
+
authType: "Anonymous",
|
|
3003
|
+
style: "RPC",
|
|
3004
|
+
reqBodyType: "formData",
|
|
3005
|
+
bodyType: "json"
|
|
3006
|
+
});
|
|
3007
|
+
return $dara44.cast(await this.callApi(params, req, runtime), new ModifyContextResponse({}));
|
|
3008
|
+
}
|
|
3009
|
+
/**
|
|
3010
|
+
* 修改上下文
|
|
3011
|
+
*
|
|
3012
|
+
* @param request - ModifyContextRequest
|
|
3013
|
+
* @returns ModifyContextResponse
|
|
3014
|
+
*/
|
|
3015
|
+
async modifyContext(request) {
|
|
3016
|
+
let runtime = new $dara44.RuntimeOptions({});
|
|
3017
|
+
return await this.modifyContextWithOptions(request, runtime);
|
|
3018
|
+
}
|
|
3019
|
+
/**
|
|
3020
|
+
* 释放 mcp session
|
|
3021
|
+
*
|
|
3022
|
+
* @param request - ReleaseMcpSessionRequest
|
|
3023
|
+
* @param runtime - runtime options for this request RuntimeOptions
|
|
3024
|
+
* @returns ReleaseMcpSessionResponse
|
|
3025
|
+
*/
|
|
3026
|
+
async releaseMcpSessionWithOptions(request, runtime) {
|
|
3027
|
+
request.validate();
|
|
3028
|
+
let body = {};
|
|
3029
|
+
if (!$dara44.isNull(request.authorization)) {
|
|
3030
|
+
body["Authorization"] = request.authorization;
|
|
3031
|
+
}
|
|
3032
|
+
if (!$dara44.isNull(request.sessionId)) {
|
|
3033
|
+
body["SessionId"] = request.sessionId;
|
|
3034
|
+
}
|
|
3035
|
+
let req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
3036
|
+
body: _openapicore.OpenApiUtil.parseToMap(body)
|
|
3037
|
+
});
|
|
3038
|
+
let params = new _openapicore.$OpenApiUtil.Params({
|
|
3039
|
+
action: "ReleaseMcpSession",
|
|
3040
|
+
version: "2025-05-06",
|
|
3041
|
+
protocol: "HTTPS",
|
|
3042
|
+
pathname: "/",
|
|
3043
|
+
method: "POST",
|
|
3044
|
+
authType: "Anonymous",
|
|
3045
|
+
style: "RPC",
|
|
3046
|
+
reqBodyType: "formData",
|
|
3047
|
+
bodyType: "json"
|
|
3048
|
+
});
|
|
3049
|
+
return $dara44.cast(await this.callApi(params, req, runtime), new ReleaseMcpSessionResponse({}));
|
|
3050
|
+
}
|
|
3051
|
+
/**
|
|
3052
|
+
* 释放 mcp session
|
|
3053
|
+
*
|
|
3054
|
+
* @param request - ReleaseMcpSessionRequest
|
|
3055
|
+
* @returns ReleaseMcpSessionResponse
|
|
3056
|
+
*/
|
|
3057
|
+
async releaseMcpSession(request) {
|
|
3058
|
+
let runtime = new $dara44.RuntimeOptions({});
|
|
3059
|
+
return await this.releaseMcpSessionWithOptions(request, runtime);
|
|
3060
|
+
}
|
|
3061
|
+
/**
|
|
3062
|
+
* 设置标签
|
|
3063
|
+
*
|
|
3064
|
+
* @param request - SetLabelRequest
|
|
3065
|
+
* @param runtime - runtime options for this request RuntimeOptions
|
|
3066
|
+
* @returns SetLabelResponse
|
|
3067
|
+
*/
|
|
3068
|
+
async setLabelWithOptions(request, runtime) {
|
|
3069
|
+
request.validate();
|
|
3070
|
+
let body = {};
|
|
3071
|
+
if (!$dara44.isNull(request.authorization)) {
|
|
3072
|
+
body["Authorization"] = request.authorization;
|
|
3073
|
+
}
|
|
3074
|
+
if (!$dara44.isNull(request.labels)) {
|
|
3075
|
+
body["Labels"] = request.labels;
|
|
3076
|
+
}
|
|
3077
|
+
if (!$dara44.isNull(request.sessionId)) {
|
|
3078
|
+
body["SessionId"] = request.sessionId;
|
|
3079
|
+
}
|
|
3080
|
+
let req = new _openapicore.$OpenApiUtil.OpenApiRequest({
|
|
3081
|
+
body: _openapicore.OpenApiUtil.parseToMap(body)
|
|
3082
|
+
});
|
|
3083
|
+
let params = new _openapicore.$OpenApiUtil.Params({
|
|
3084
|
+
action: "SetLabel",
|
|
3085
|
+
version: "2025-05-06",
|
|
3086
|
+
protocol: "HTTPS",
|
|
3087
|
+
pathname: "/",
|
|
3088
|
+
method: "POST",
|
|
3089
|
+
authType: "Anonymous",
|
|
3090
|
+
style: "RPC",
|
|
3091
|
+
reqBodyType: "formData",
|
|
3092
|
+
bodyType: "json"
|
|
3093
|
+
});
|
|
3094
|
+
return $dara44.cast(await this.callApi(params, req, runtime), new SetLabelResponse({}));
|
|
3095
|
+
}
|
|
3096
|
+
/**
|
|
3097
|
+
* 设置标签
|
|
3098
|
+
*
|
|
3099
|
+
* @param request - SetLabelRequest
|
|
3100
|
+
* @returns SetLabelResponse
|
|
3101
|
+
*/
|
|
3102
|
+
async setLabel(request) {
|
|
3103
|
+
let runtime = new $dara44.RuntimeOptions({});
|
|
3104
|
+
return await this.setLabelWithOptions(request, runtime);
|
|
3105
|
+
}
|
|
3106
|
+
};
|
|
3107
|
+
__name(_Client, "Client");
|
|
3108
|
+
var Client = _Client;
|
|
3109
|
+
|
|
3110
|
+
// src/oss/oss.ts
|
|
3111
|
+
var _Oss = class _Oss {
|
|
3112
|
+
/**
|
|
3113
|
+
* Initialize an Oss object.
|
|
3114
|
+
*
|
|
3115
|
+
* @param session - The Session instance that this Oss belongs to.
|
|
3116
|
+
*/
|
|
3117
|
+
constructor(session) {
|
|
3118
|
+
this.session = session;
|
|
3119
|
+
}
|
|
3120
|
+
/**
|
|
3121
|
+
* Helper method to call MCP tools and handle common response processing
|
|
3122
|
+
*
|
|
3123
|
+
* @param toolName - Name of the MCP tool to call
|
|
3124
|
+
* @param args - Arguments to pass to the tool
|
|
3125
|
+
* @param defaultErrorMsg - Default error message if specific error details are not available
|
|
3126
|
+
* @returns A CallMcpToolResult with the response data
|
|
3127
|
+
* @throws APIError if the call fails
|
|
3128
|
+
*/
|
|
3129
|
+
async callMcpTool(toolName, args, defaultErrorMsg) {
|
|
3130
|
+
try {
|
|
3131
|
+
const callToolRequest = new CallMcpToolRequest({
|
|
3132
|
+
authorization: `Bearer ${this.session.getAPIKey()}`,
|
|
3133
|
+
sessionId: this.session.getSessionId(),
|
|
3134
|
+
name: toolName,
|
|
3135
|
+
args: JSON.stringify(args)
|
|
3136
|
+
});
|
|
3137
|
+
log(`API Call: CallMcpTool - ${toolName}`);
|
|
3138
|
+
log(`Request: SessionId=${this.session.getSessionId()}, Args=${JSON.stringify(args)}`);
|
|
3139
|
+
const response = await this.session.getClient().callMcpTool(callToolRequest);
|
|
3140
|
+
log(`Response from CallMcpTool - ${toolName}:`, response.body);
|
|
3141
|
+
if (!_optionalChain([response, 'access', _11 => _11.body, 'optionalAccess', _12 => _12.data])) {
|
|
3142
|
+
throw new Error("Invalid response data format");
|
|
3143
|
+
}
|
|
3144
|
+
const data = response.body.data;
|
|
3145
|
+
const result = {
|
|
3146
|
+
data,
|
|
3147
|
+
statusCode: response.statusCode || 0,
|
|
3148
|
+
isError: false
|
|
3149
|
+
};
|
|
3150
|
+
if (data.isError === true) {
|
|
3151
|
+
result.isError = true;
|
|
3152
|
+
const contentArray = data.content;
|
|
3153
|
+
if (contentArray && contentArray.length > 0) {
|
|
3154
|
+
result.content = contentArray;
|
|
3155
|
+
if (_optionalChain([contentArray, 'access', _13 => _13[0], 'optionalAccess', _14 => _14.text])) {
|
|
3156
|
+
result.errorMsg = contentArray[0].text;
|
|
3157
|
+
throw new Error(contentArray[0].text);
|
|
3158
|
+
}
|
|
3159
|
+
}
|
|
3160
|
+
throw new Error(defaultErrorMsg);
|
|
3161
|
+
}
|
|
3162
|
+
if (Array.isArray(data.content)) {
|
|
3163
|
+
result.content = data.content;
|
|
3164
|
+
if (result.content.length > 0) {
|
|
3165
|
+
const textParts = [];
|
|
3166
|
+
for (const item of result.content) {
|
|
3167
|
+
if (item && typeof item === "object" && item.text && typeof item.text === "string") {
|
|
3168
|
+
textParts.push(item.text);
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
result.textContent = textParts.join("\n");
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3174
|
+
return result;
|
|
3175
|
+
} catch (error) {
|
|
3176
|
+
logError(`Error calling CallMcpTool - ${toolName}:`, error);
|
|
3177
|
+
throw new APIError(`Failed to call ${toolName}: ${error}`);
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
/**
|
|
3181
|
+
* Initialize OSS environment variables with the specified credentials.
|
|
3182
|
+
*
|
|
3183
|
+
* @param accessKeyId - The Access Key ID for OSS authentication.
|
|
3184
|
+
* @param accessKeySecret - The Access Key Secret for OSS authentication.
|
|
3185
|
+
* @param securityToken - The security token for OSS authentication.
|
|
3186
|
+
* @param endpoint - The OSS service endpoint. If not specified, the default is used.
|
|
3187
|
+
* @param region - The OSS region. If not specified, the default is used.
|
|
3188
|
+
* @returns The extracted text content from the API response
|
|
3189
|
+
*/
|
|
3190
|
+
async envInit(accessKeyId, accessKeySecret, securityToken, endpoint, region) {
|
|
3191
|
+
const args = {
|
|
3192
|
+
access_key_id: accessKeyId,
|
|
3193
|
+
access_key_secret: accessKeySecret,
|
|
3194
|
+
security_token: securityToken
|
|
3195
|
+
};
|
|
3196
|
+
if (endpoint) {
|
|
3197
|
+
args.endpoint = endpoint;
|
|
3198
|
+
}
|
|
3199
|
+
if (region) {
|
|
3200
|
+
args.region = region;
|
|
3201
|
+
}
|
|
3202
|
+
const result = await this.callMcpTool("oss_env_init", args, "error initializing OSS environment");
|
|
3203
|
+
return result.textContent || "";
|
|
3204
|
+
}
|
|
3205
|
+
/**
|
|
3206
|
+
* Create an OSS client with the provided credentials.
|
|
3207
|
+
*
|
|
3208
|
+
* @param accessKeyId - The Access Key ID for OSS authentication.
|
|
3209
|
+
* @param accessKeySecret - The Access Key Secret for OSS authentication.
|
|
3210
|
+
* @param endpoint - The OSS service endpoint. If not specified, the default is used.
|
|
3211
|
+
* @param region - The OSS region. If not specified, the default is used.
|
|
3212
|
+
* @returns The extracted text content from the API response
|
|
3213
|
+
*/
|
|
3214
|
+
async createClient(accessKeyId, accessKeySecret, endpoint, region) {
|
|
3215
|
+
const args = {
|
|
3216
|
+
access_key_id: accessKeyId,
|
|
3217
|
+
access_key_secret: accessKeySecret
|
|
3218
|
+
};
|
|
3219
|
+
if (endpoint) {
|
|
3220
|
+
args.endpoint = endpoint;
|
|
3221
|
+
}
|
|
3222
|
+
if (region) {
|
|
3223
|
+
args.region = region;
|
|
3224
|
+
}
|
|
3225
|
+
const result = await this.callMcpTool("oss_client_create", args, "error creating OSS client");
|
|
3226
|
+
return result.textContent || "";
|
|
3227
|
+
}
|
|
3228
|
+
/**
|
|
3229
|
+
* Upload a local file or directory to OSS.
|
|
3230
|
+
*
|
|
3231
|
+
* @param bucket - OSS bucket name.
|
|
3232
|
+
* @param object - Object key in OSS.
|
|
3233
|
+
* @param path - Local file or directory path to upload.
|
|
3234
|
+
* @returns The extracted text content from the API response
|
|
3235
|
+
*/
|
|
3236
|
+
async upload(bucket, object, path2) {
|
|
3237
|
+
const args = {
|
|
3238
|
+
bucket,
|
|
3239
|
+
object,
|
|
3240
|
+
path: path2
|
|
3241
|
+
};
|
|
3242
|
+
const result = await this.callMcpTool("oss_upload", args, "error uploading to OSS");
|
|
3243
|
+
return result.textContent || "";
|
|
3244
|
+
}
|
|
3245
|
+
/**
|
|
3246
|
+
* Upload a local file or directory to OSS using a pre-signed URL.
|
|
3247
|
+
*
|
|
3248
|
+
* @param url - Pre-signed URL for anonymous upload.
|
|
3249
|
+
* @param path - Local file or directory path to upload.
|
|
3250
|
+
* @returns The extracted text content from the API response
|
|
3251
|
+
*/
|
|
3252
|
+
async uploadAnonymous(url, path2) {
|
|
3253
|
+
const args = {
|
|
3254
|
+
url,
|
|
3255
|
+
path: path2
|
|
3256
|
+
};
|
|
3257
|
+
const result = await this.callMcpTool("oss_upload_annon", args, "error uploading anonymously");
|
|
3258
|
+
return result.textContent || "";
|
|
3259
|
+
}
|
|
3260
|
+
/**
|
|
3261
|
+
* Download an object from OSS to a local file or directory.
|
|
3262
|
+
*
|
|
3263
|
+
* @param bucket - OSS bucket name.
|
|
3264
|
+
* @param object - Object key in OSS.
|
|
3265
|
+
* @param path - Local file or directory path to save the downloaded content.
|
|
3266
|
+
* @returns The extracted text content from the API response
|
|
3267
|
+
*/
|
|
3268
|
+
async download(bucket, object, path2) {
|
|
3269
|
+
const args = {
|
|
3270
|
+
bucket,
|
|
3271
|
+
object,
|
|
3272
|
+
path: path2
|
|
3273
|
+
};
|
|
3274
|
+
const result = await this.callMcpTool("oss_download", args, "error downloading from OSS");
|
|
3275
|
+
return result.textContent || "";
|
|
3276
|
+
}
|
|
3277
|
+
/**
|
|
3278
|
+
* Download an object from OSS using a pre-signed URL.
|
|
3279
|
+
*
|
|
3280
|
+
* @param url - Pre-signed URL for anonymous download.
|
|
3281
|
+
* @param path - Local file or directory path to save the downloaded content.
|
|
3282
|
+
* @returns The extracted text content from the API response
|
|
3283
|
+
*/
|
|
3284
|
+
async downloadAnonymous(url, path2) {
|
|
3285
|
+
const args = {
|
|
3286
|
+
url,
|
|
3287
|
+
path: path2
|
|
3288
|
+
};
|
|
3289
|
+
const result = await this.callMcpTool("oss_download_annon", args, "error downloading anonymously");
|
|
3290
|
+
return result.textContent || "";
|
|
3291
|
+
}
|
|
3292
|
+
};
|
|
3293
|
+
__name(_Oss, "Oss");
|
|
3294
|
+
var Oss = _Oss;
|
|
3295
|
+
|
|
3296
|
+
// src/application/application.ts
|
|
3297
|
+
init_cjs_shims();
|
|
3298
|
+
var _Application = class _Application {
|
|
3299
|
+
/**
|
|
3300
|
+
* Creates a new Application instance.
|
|
3301
|
+
* @param session The session object that provides access to the AgentBay API.
|
|
3302
|
+
*/
|
|
3303
|
+
constructor(session) {
|
|
3304
|
+
this.session = session;
|
|
3305
|
+
}
|
|
3306
|
+
/**
|
|
3307
|
+
* Helper method to call MCP tools and handle common response processing
|
|
3308
|
+
*
|
|
3309
|
+
* @param toolName - Name of the MCP tool to call
|
|
3310
|
+
* @param args - Arguments to pass to the tool
|
|
3311
|
+
* @param defaultErrorMsg - Default error message if specific error details are not available
|
|
3312
|
+
* @returns A CallMcpToolResult with the response data
|
|
3313
|
+
* @throws APIError if the call fails
|
|
3314
|
+
*/
|
|
3315
|
+
async callMcpTool(toolName, args, defaultErrorMsg) {
|
|
3316
|
+
try {
|
|
3317
|
+
const argsJSON = JSON.stringify(args);
|
|
3318
|
+
const request = new CallMcpToolRequest({
|
|
3319
|
+
authorization: `Bearer ${this.session.getAPIKey()}`,
|
|
3320
|
+
sessionId: this.session.getSessionId(),
|
|
3321
|
+
name: toolName,
|
|
3322
|
+
args: argsJSON
|
|
3323
|
+
});
|
|
3324
|
+
log(`API Call: CallMcpTool - ${toolName}`);
|
|
3325
|
+
log(`Request: SessionId=${request.sessionId}, Args=${request.args}`);
|
|
3326
|
+
const client = this.session.getClient();
|
|
3327
|
+
const response = await client.callMcpTool(request);
|
|
3328
|
+
if (response && response.body) {
|
|
3329
|
+
log(`Response from CallMcpTool - ${toolName}:`, response.body);
|
|
3330
|
+
}
|
|
3331
|
+
if (!_optionalChain([response, 'access', _15 => _15.body, 'optionalAccess', _16 => _16.data])) {
|
|
3332
|
+
throw new Error("Invalid response data format");
|
|
3333
|
+
}
|
|
3334
|
+
const data = response.body.data;
|
|
3335
|
+
const result = {
|
|
3336
|
+
data,
|
|
3337
|
+
statusCode: response.statusCode || 0,
|
|
3338
|
+
isError: false
|
|
3339
|
+
};
|
|
3340
|
+
if (data.isError === true) {
|
|
3341
|
+
result.isError = true;
|
|
3342
|
+
const contentArray = data.content;
|
|
3343
|
+
if (contentArray && contentArray.length > 0) {
|
|
3344
|
+
result.content = contentArray;
|
|
3345
|
+
if (_optionalChain([contentArray, 'access', _17 => _17[0], 'optionalAccess', _18 => _18.text])) {
|
|
3346
|
+
result.errorMsg = contentArray[0].text;
|
|
3347
|
+
throw new Error(contentArray[0].text);
|
|
3348
|
+
}
|
|
3349
|
+
}
|
|
3350
|
+
throw new Error(defaultErrorMsg);
|
|
3351
|
+
}
|
|
3352
|
+
if (Array.isArray(data.content)) {
|
|
3353
|
+
result.content = data.content;
|
|
3354
|
+
if (result.content.length > 0) {
|
|
3355
|
+
const textParts = [];
|
|
3356
|
+
for (const item of result.content) {
|
|
3357
|
+
if (item && typeof item === "object" && item.text && typeof item.text === "string") {
|
|
3358
|
+
textParts.push(item.text);
|
|
3359
|
+
}
|
|
3360
|
+
}
|
|
3361
|
+
result.textContent = textParts.join("\n");
|
|
3362
|
+
}
|
|
3363
|
+
}
|
|
3364
|
+
return result;
|
|
3365
|
+
} catch (error) {
|
|
3366
|
+
logError(`Error calling CallMcpTool - ${toolName}:`, error);
|
|
3367
|
+
throw new APIError(`Failed to call ${toolName}: ${error}`);
|
|
3368
|
+
}
|
|
3369
|
+
}
|
|
3370
|
+
/**
|
|
3371
|
+
* Helper method to parse JSON string into objects
|
|
3372
|
+
*/
|
|
3373
|
+
parseJSON(jsonString) {
|
|
3374
|
+
try {
|
|
3375
|
+
return JSON.parse(jsonString);
|
|
3376
|
+
} catch (error) {
|
|
3377
|
+
throw new Error(`Failed to parse JSON: ${error}`);
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
/**
|
|
3381
|
+
* Retrieves a list of installed applications.
|
|
3382
|
+
* @param startMenu Whether to include applications from the start menu. Defaults to true.
|
|
3383
|
+
* @param desktop Whether to include applications from the desktop. Defaults to true.
|
|
3384
|
+
* @param ignoreSystemApps Whether to ignore system applications. Defaults to true.
|
|
3385
|
+
* @returns Array of InstalledApp objects
|
|
3386
|
+
* @throws Error if the operation fails.
|
|
3387
|
+
*/
|
|
3388
|
+
async getInstalledApps(startMenu = true, desktop = true, ignoreSystemApps = true) {
|
|
3389
|
+
const args = {
|
|
3390
|
+
start_menu: startMenu,
|
|
3391
|
+
desktop,
|
|
3392
|
+
ignore_system_apps: ignoreSystemApps
|
|
3393
|
+
};
|
|
3394
|
+
const result = await this.callMcpTool("get_installed_apps", args, "Failed to get installed apps");
|
|
3395
|
+
if (!result.textContent) {
|
|
3396
|
+
return [];
|
|
3397
|
+
}
|
|
3398
|
+
return this.parseJSON(result.textContent);
|
|
3399
|
+
}
|
|
3400
|
+
/**
|
|
3401
|
+
* Starts an application with the given command and optional working directory.
|
|
3402
|
+
* @param startCmd The command to start the application.
|
|
3403
|
+
* @param workDirectory The working directory for the application. Defaults to an empty string.
|
|
3404
|
+
* @returns Array of Process objects representing the started processes
|
|
3405
|
+
* @throws Error if the operation fails.
|
|
3406
|
+
*/
|
|
3407
|
+
async startApp(startCmd, workDirectory = "") {
|
|
3408
|
+
const args = {
|
|
3409
|
+
start_cmd: startCmd
|
|
3410
|
+
};
|
|
3411
|
+
if (workDirectory) {
|
|
3412
|
+
args.work_directory = workDirectory;
|
|
3413
|
+
}
|
|
3414
|
+
const result = await this.callMcpTool("start_app", args, "Failed to start app");
|
|
3415
|
+
if (!result.textContent) {
|
|
3416
|
+
return [];
|
|
3417
|
+
}
|
|
3418
|
+
return this.parseJSON(result.textContent);
|
|
3419
|
+
}
|
|
3420
|
+
/**
|
|
3421
|
+
* Stops an application by process name.
|
|
3422
|
+
* @param pname The name of the process to stop.
|
|
3423
|
+
* @throws Error if the operation fails.
|
|
3424
|
+
*/
|
|
3425
|
+
async stopAppByPName(pname) {
|
|
3426
|
+
const args = {
|
|
3427
|
+
pname
|
|
3428
|
+
};
|
|
3429
|
+
await this.callMcpTool("stop_app_by_pname", args, "Failed to stop app by pname");
|
|
3430
|
+
}
|
|
3431
|
+
/**
|
|
3432
|
+
* Stops an application by process ID.
|
|
3433
|
+
* @param pid The ID of the process to stop.
|
|
3434
|
+
* @throws Error if the operation fails.
|
|
3435
|
+
*/
|
|
3436
|
+
async stopAppByPID(pid) {
|
|
3437
|
+
const args = {
|
|
3438
|
+
pid
|
|
3439
|
+
};
|
|
3440
|
+
await this.callMcpTool("stop_app_by_pid", args, "Failed to stop app by pid");
|
|
3441
|
+
}
|
|
3442
|
+
/**
|
|
3443
|
+
* Stops an application by stop command.
|
|
3444
|
+
* @param stopCmd The command to stop the application.
|
|
3445
|
+
* @throws Error if the operation fails.
|
|
3446
|
+
*/
|
|
3447
|
+
async stopAppByCmd(stopCmd) {
|
|
3448
|
+
const args = {
|
|
3449
|
+
stop_cmd: stopCmd
|
|
3450
|
+
};
|
|
3451
|
+
await this.callMcpTool("stop_app_by_cmd", args, "Failed to stop app by command");
|
|
3452
|
+
}
|
|
3453
|
+
/**
|
|
3454
|
+
* Lists all currently visible applications.
|
|
3455
|
+
* @returns Array of Process objects representing the visible processes
|
|
3456
|
+
* @throws Error if the operation fails.
|
|
3457
|
+
*/
|
|
3458
|
+
async listVisibleApps() {
|
|
3459
|
+
const args = {};
|
|
3460
|
+
const result = await this.callMcpTool("list_visible_apps", args, "Failed to list visible apps");
|
|
3461
|
+
if (!result.textContent) {
|
|
3462
|
+
return [];
|
|
3463
|
+
}
|
|
3464
|
+
return this.parseJSON(result.textContent);
|
|
3465
|
+
}
|
|
3466
|
+
};
|
|
3467
|
+
__name(_Application, "Application");
|
|
3468
|
+
var Application = _Application;
|
|
3469
|
+
|
|
3470
|
+
// src/window/window.ts
|
|
3471
|
+
init_cjs_shims();
|
|
3472
|
+
var _WindowManager = class _WindowManager {
|
|
3473
|
+
/**
|
|
3474
|
+
* Creates a new WindowManager instance.
|
|
3475
|
+
* @param session The session object that provides access to the AgentBay API.
|
|
3476
|
+
*/
|
|
3477
|
+
constructor(session) {
|
|
3478
|
+
this.session = session;
|
|
3479
|
+
}
|
|
3480
|
+
/**
|
|
3481
|
+
* Helper method to call MCP tools and handle common response processing
|
|
3482
|
+
*
|
|
3483
|
+
* @param toolName - Name of the MCP tool to call
|
|
3484
|
+
* @param args - Arguments to pass to the tool
|
|
3485
|
+
* @param defaultErrorMsg - Default error message if specific error details are not available
|
|
3486
|
+
* @returns A CallMcpToolResult with the response data
|
|
3487
|
+
* @throws APIError if the call fails
|
|
3488
|
+
*/
|
|
3489
|
+
async callMcpTool(toolName, args, defaultErrorMsg) {
|
|
3490
|
+
try {
|
|
3491
|
+
const argsJSON = JSON.stringify(args);
|
|
3492
|
+
const request = new CallMcpToolRequest({
|
|
3493
|
+
authorization: `Bearer ${this.session.getAPIKey()}`,
|
|
3494
|
+
sessionId: this.session.getSessionId(),
|
|
3495
|
+
name: toolName,
|
|
3496
|
+
args: argsJSON
|
|
3497
|
+
});
|
|
3498
|
+
log(`API Call: CallMcpTool - ${toolName}`);
|
|
3499
|
+
log(`Request: SessionId=${request.sessionId}, Args=${request.args}`);
|
|
3500
|
+
const response = await this.session.getClient().callMcpTool(request);
|
|
3501
|
+
if (response && response.body) {
|
|
3502
|
+
log(`Response from CallMcpTool - ${toolName}:`, response.body);
|
|
3503
|
+
}
|
|
3504
|
+
if (!_optionalChain([response, 'access', _19 => _19.body, 'optionalAccess', _20 => _20.data])) {
|
|
3505
|
+
throw new Error("Invalid response data format");
|
|
3506
|
+
}
|
|
3507
|
+
const data = response.body.data;
|
|
3508
|
+
const result = {
|
|
3509
|
+
data,
|
|
3510
|
+
statusCode: response.statusCode || 0,
|
|
3511
|
+
isError: false
|
|
3512
|
+
};
|
|
3513
|
+
if (data.isError === true) {
|
|
3514
|
+
result.isError = true;
|
|
3515
|
+
const contentArray = data.content;
|
|
3516
|
+
if (contentArray && contentArray.length > 0) {
|
|
3517
|
+
result.content = contentArray;
|
|
3518
|
+
if (_optionalChain([contentArray, 'access', _21 => _21[0], 'optionalAccess', _22 => _22.text])) {
|
|
3519
|
+
result.errorMsg = contentArray[0].text;
|
|
3520
|
+
throw new Error(contentArray[0].text);
|
|
3521
|
+
}
|
|
3522
|
+
}
|
|
3523
|
+
throw new Error(defaultErrorMsg);
|
|
3524
|
+
}
|
|
3525
|
+
if (Array.isArray(data.content)) {
|
|
3526
|
+
result.content = data.content;
|
|
3527
|
+
if (result.content.length > 0) {
|
|
3528
|
+
const textParts = [];
|
|
3529
|
+
for (const item of result.content) {
|
|
3530
|
+
if (item && typeof item === "object" && item.text && typeof item.text === "string") {
|
|
3531
|
+
textParts.push(item.text);
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3534
|
+
result.textContent = textParts.join("\n");
|
|
3535
|
+
}
|
|
3536
|
+
}
|
|
3537
|
+
return result;
|
|
3538
|
+
} catch (error) {
|
|
3539
|
+
logError(`Error calling CallMcpTool - ${toolName}:`, error);
|
|
3540
|
+
throw new APIError(`Failed to call ${toolName}: ${error}`);
|
|
3541
|
+
}
|
|
3542
|
+
}
|
|
3543
|
+
/**
|
|
3544
|
+
* Helper method to parse JSON string into Window objects
|
|
3545
|
+
* @param jsonStr - JSON string to parse
|
|
3546
|
+
* @returns Array of Window objects or single Window object
|
|
3547
|
+
*/
|
|
3548
|
+
parseWindowsFromJSON(jsonStr) {
|
|
3549
|
+
try {
|
|
3550
|
+
const parsed = JSON.parse(jsonStr);
|
|
3551
|
+
return Array.isArray(parsed) ? parsed : [parsed];
|
|
3552
|
+
} catch (error) {
|
|
3553
|
+
throw new Error(`Failed to parse window data: ${error}`);
|
|
3554
|
+
}
|
|
3555
|
+
}
|
|
3556
|
+
/**
|
|
3557
|
+
* Lists all root windows in the system.
|
|
3558
|
+
* @returns Array of Window objects
|
|
3559
|
+
* @throws Error if the operation fails.
|
|
3560
|
+
*/
|
|
3561
|
+
async listRootWindows() {
|
|
3562
|
+
const args = {};
|
|
3563
|
+
const result = await this.callMcpTool("list_root_windows", args, "Failed to list root windows");
|
|
3564
|
+
if (!result.textContent) {
|
|
3565
|
+
return [];
|
|
3566
|
+
}
|
|
3567
|
+
return this.parseWindowsFromJSON(result.textContent);
|
|
3568
|
+
}
|
|
3569
|
+
/**
|
|
3570
|
+
* Gets the currently active window.
|
|
3571
|
+
* @returns Window object or null if no active window
|
|
3572
|
+
* @throws Error if the operation fails.
|
|
3573
|
+
*/
|
|
3574
|
+
async getActiveWindow() {
|
|
3575
|
+
const args = {};
|
|
3576
|
+
const result = await this.callMcpTool("get_active_window", args, "Failed to get active window");
|
|
3577
|
+
if (!result.textContent) {
|
|
3578
|
+
return null;
|
|
3579
|
+
}
|
|
3580
|
+
const windows = this.parseWindowsFromJSON(result.textContent);
|
|
3581
|
+
return windows.length > 0 ? windows[0] : null;
|
|
3582
|
+
}
|
|
3583
|
+
/**
|
|
3584
|
+
* Activates a window by ID.
|
|
3585
|
+
* @param windowId The ID of the window to activate.
|
|
3586
|
+
* @throws Error if the operation fails.
|
|
3587
|
+
*/
|
|
3588
|
+
async activateWindow(windowId) {
|
|
3589
|
+
const args = {
|
|
3590
|
+
window_id: windowId
|
|
3591
|
+
};
|
|
3592
|
+
await this.callMcpTool("activate_window", args, "Failed to activate window");
|
|
3593
|
+
}
|
|
3594
|
+
/**
|
|
3595
|
+
* Maximizes a window by ID.
|
|
3596
|
+
* @param windowId The ID of the window to maximize.
|
|
3597
|
+
* @throws Error if the operation fails.
|
|
3598
|
+
*/
|
|
3599
|
+
async maximizeWindow(windowId) {
|
|
3600
|
+
const args = {
|
|
3601
|
+
window_id: windowId
|
|
3602
|
+
};
|
|
3603
|
+
await this.callMcpTool("maximize_window", args, "Failed to maximize window");
|
|
3604
|
+
}
|
|
3605
|
+
/**
|
|
3606
|
+
* Minimizes a window by ID.
|
|
3607
|
+
* @param windowId The ID of the window to minimize.
|
|
3608
|
+
* @throws Error if the operation fails.
|
|
3609
|
+
*/
|
|
3610
|
+
async minimizeWindow(windowId) {
|
|
3611
|
+
const args = {
|
|
3612
|
+
window_id: windowId
|
|
3613
|
+
};
|
|
3614
|
+
await this.callMcpTool("minimize_window", args, "Failed to minimize window");
|
|
3615
|
+
}
|
|
3616
|
+
/**
|
|
3617
|
+
* Restores a window by ID.
|
|
3618
|
+
* @param windowId The ID of the window to restore.
|
|
3619
|
+
* @throws Error if the operation fails.
|
|
3620
|
+
*/
|
|
3621
|
+
async restoreWindow(windowId) {
|
|
3622
|
+
const args = {
|
|
3623
|
+
window_id: windowId
|
|
3624
|
+
};
|
|
3625
|
+
await this.callMcpTool("restore_window", args, "Failed to restore window");
|
|
3626
|
+
}
|
|
3627
|
+
/**
|
|
3628
|
+
* Closes a window by ID.
|
|
3629
|
+
* @param windowId The ID of the window to close.
|
|
3630
|
+
* @throws Error if the operation fails.
|
|
3631
|
+
*/
|
|
3632
|
+
async closeWindow(windowId) {
|
|
3633
|
+
const args = {
|
|
3634
|
+
window_id: windowId
|
|
3635
|
+
};
|
|
3636
|
+
await this.callMcpTool("close_window", args, "Failed to close window");
|
|
3637
|
+
}
|
|
3638
|
+
/**
|
|
3639
|
+
* Sets a window to fullscreen by ID.
|
|
3640
|
+
* @param windowId The ID of the window to set to fullscreen.
|
|
3641
|
+
* @throws Error if the operation fails.
|
|
3642
|
+
*/
|
|
3643
|
+
async fullscreenWindow(windowId) {
|
|
3644
|
+
const args = {
|
|
3645
|
+
window_id: windowId
|
|
3646
|
+
};
|
|
3647
|
+
await this.callMcpTool("fullscreen_window", args, "Failed to set window to fullscreen");
|
|
3648
|
+
}
|
|
3649
|
+
/**
|
|
3650
|
+
* Resizes a window by ID.
|
|
3651
|
+
* @param windowId The ID of the window to resize.
|
|
3652
|
+
* @param width The new width of the window.
|
|
3653
|
+
* @param height The new height of the window.
|
|
3654
|
+
* @throws Error if the operation fails.
|
|
3655
|
+
*/
|
|
3656
|
+
async resizeWindow(windowId, width, height) {
|
|
3657
|
+
const args = {
|
|
3658
|
+
window_id: windowId,
|
|
3659
|
+
width,
|
|
3660
|
+
height
|
|
3661
|
+
};
|
|
3662
|
+
await this.callMcpTool("resize_window", args, "Failed to resize window");
|
|
3663
|
+
}
|
|
3664
|
+
/**
|
|
3665
|
+
* Enables or disables focus mode.
|
|
3666
|
+
* @param on Whether to enable focus mode.
|
|
3667
|
+
* @throws Error if the operation fails.
|
|
3668
|
+
*/
|
|
3669
|
+
async focusMode(on) {
|
|
3670
|
+
const args = {
|
|
3671
|
+
on
|
|
3672
|
+
};
|
|
3673
|
+
await this.callMcpTool("focus_mode", args, "Failed to set focus mode");
|
|
3674
|
+
}
|
|
3675
|
+
};
|
|
3676
|
+
__name(_WindowManager, "WindowManager");
|
|
3677
|
+
var WindowManager = _WindowManager;
|
|
3678
|
+
|
|
3679
|
+
// src/ui/ui.ts
|
|
3680
|
+
init_cjs_shims();
|
|
3681
|
+
var KeyCode = {
|
|
3682
|
+
HOME: 3,
|
|
3683
|
+
BACK: 4,
|
|
3684
|
+
VOLUME_UP: 24,
|
|
3685
|
+
VOLUME_DOWN: 25,
|
|
3686
|
+
POWER: 26,
|
|
3687
|
+
MENU: 82
|
|
3688
|
+
};
|
|
3689
|
+
var _UI = class _UI {
|
|
3690
|
+
/**
|
|
3691
|
+
* Initialize a UI object.
|
|
3692
|
+
*
|
|
3693
|
+
* @param session - The Session instance that this UI belongs to.
|
|
3694
|
+
*/
|
|
3695
|
+
constructor(session) {
|
|
3696
|
+
this.session = session;
|
|
3697
|
+
}
|
|
3698
|
+
/**
|
|
3699
|
+
* Helper method to call MCP tools and handle common response processing
|
|
3700
|
+
*
|
|
3701
|
+
* @param toolName - Name of the MCP tool to call
|
|
3702
|
+
* @param args - Arguments to pass to the tool
|
|
3703
|
+
* @param defaultErrorMsg - Default error message if specific error details are not available
|
|
3704
|
+
* @returns A CallMcpToolResult with the response data
|
|
3705
|
+
* @throws APIError if the call fails
|
|
3706
|
+
*/
|
|
3707
|
+
async callMcpTool(toolName, args, defaultErrorMsg) {
|
|
3708
|
+
try {
|
|
3709
|
+
const argsJSON = JSON.stringify(args);
|
|
3710
|
+
const callToolRequest = new CallMcpToolRequest({
|
|
3711
|
+
authorization: `Bearer ${this.session.getAPIKey()}`,
|
|
3712
|
+
sessionId: this.session.getSessionId(),
|
|
3713
|
+
name: toolName,
|
|
3714
|
+
args: argsJSON
|
|
3715
|
+
});
|
|
3716
|
+
log(`API Call: CallMcpTool - ${toolName}`);
|
|
3717
|
+
log(`Request: SessionId=${this.session.getSessionId()}, Args=${argsJSON}`);
|
|
3718
|
+
const response = await this.session.getClient().callMcpTool(callToolRequest);
|
|
3719
|
+
log(`Response from CallMcpTool - ${toolName}:`, response.body);
|
|
3720
|
+
if (!_optionalChain([response, 'access', _23 => _23.body, 'optionalAccess', _24 => _24.data])) {
|
|
3721
|
+
throw new Error("Invalid response data format");
|
|
3722
|
+
}
|
|
3723
|
+
const data = response.body.data;
|
|
3724
|
+
const result = {
|
|
3725
|
+
data,
|
|
3726
|
+
statusCode: response.statusCode || 0,
|
|
3727
|
+
isError: false
|
|
3728
|
+
};
|
|
3729
|
+
if (data.isError === true) {
|
|
3730
|
+
result.isError = true;
|
|
3731
|
+
const contentArray = data.content;
|
|
3732
|
+
if (contentArray && contentArray.length > 0) {
|
|
3733
|
+
result.content = contentArray;
|
|
3734
|
+
if (_optionalChain([contentArray, 'access', _25 => _25[0], 'optionalAccess', _26 => _26.text])) {
|
|
3735
|
+
result.errorMsg = contentArray[0].text;
|
|
3736
|
+
throw new Error(contentArray[0].text);
|
|
3737
|
+
}
|
|
3738
|
+
}
|
|
3739
|
+
throw new Error(defaultErrorMsg);
|
|
3740
|
+
}
|
|
3741
|
+
if (Array.isArray(data.content)) {
|
|
3742
|
+
result.content = data.content;
|
|
3743
|
+
if (result.content.length > 0) {
|
|
3744
|
+
const textParts = [];
|
|
3745
|
+
for (const item of result.content) {
|
|
3746
|
+
if (item && typeof item === "object" && item.text && typeof item.text === "string") {
|
|
3747
|
+
textParts.push(item.text);
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3750
|
+
result.textContent = textParts.join("\n");
|
|
3751
|
+
}
|
|
3752
|
+
}
|
|
3753
|
+
return result;
|
|
3754
|
+
} catch (error) {
|
|
3755
|
+
logError(`Error calling CallMcpTool - ${toolName}:`, error);
|
|
3756
|
+
throw new APIError(`Failed to call ${toolName}: ${error}`);
|
|
3757
|
+
}
|
|
3758
|
+
}
|
|
3759
|
+
/**
|
|
3760
|
+
* Retrieves all clickable UI elements within the specified timeout.
|
|
3761
|
+
*
|
|
3762
|
+
* @param timeoutMs - The timeout in milliseconds. Default is 2000ms.
|
|
3763
|
+
* @returns An array of UIElement objects
|
|
3764
|
+
* @throws Error if the operation fails.
|
|
3765
|
+
*/
|
|
3766
|
+
async getClickableUIElements(timeoutMs = 2e3) {
|
|
3767
|
+
const args = {
|
|
3768
|
+
timeout_ms: timeoutMs
|
|
3769
|
+
};
|
|
3770
|
+
const result = await this.callMcpTool("get_clickable_ui_elements", args, "Failed to get clickable UI elements");
|
|
3771
|
+
if (!result.textContent) {
|
|
3772
|
+
return [];
|
|
3773
|
+
}
|
|
3774
|
+
try {
|
|
3775
|
+
return JSON.parse(result.textContent);
|
|
3776
|
+
} catch (error) {
|
|
3777
|
+
logError("Failed to parse clickable UI elements:", error);
|
|
3778
|
+
throw new APIError(`Failed to parse clickable UI elements: ${error}`);
|
|
3779
|
+
}
|
|
3780
|
+
}
|
|
3781
|
+
/**
|
|
3782
|
+
* Retrieves all UI elements within the specified timeout.
|
|
3783
|
+
*
|
|
3784
|
+
* @param timeoutMs - The timeout in milliseconds. Default is 2000ms.
|
|
3785
|
+
* @returns An array of UIElement objects
|
|
3786
|
+
* @throws Error if the operation fails.
|
|
3787
|
+
*/
|
|
3788
|
+
async getAllUIElements(timeoutMs = 2e3) {
|
|
3789
|
+
const args = {
|
|
3790
|
+
timeout_ms: timeoutMs
|
|
3791
|
+
};
|
|
3792
|
+
const result = await this.callMcpTool("get_all_ui_elements", args, "Failed to get all UI elements");
|
|
3793
|
+
if (!result.textContent) {
|
|
3794
|
+
return [];
|
|
3795
|
+
}
|
|
3796
|
+
try {
|
|
3797
|
+
return JSON.parse(result.textContent);
|
|
3798
|
+
} catch (error) {
|
|
3799
|
+
logError("Failed to parse all UI elements:", error);
|
|
3800
|
+
throw new APIError(`Failed to parse all UI elements: ${error}`);
|
|
3801
|
+
}
|
|
3802
|
+
}
|
|
3803
|
+
/**
|
|
3804
|
+
* Sends a key press event.
|
|
3805
|
+
*
|
|
3806
|
+
* @param key - The key code to send.
|
|
3807
|
+
* @returns The extracted text content from the API response
|
|
3808
|
+
* @throws Error if the operation fails.
|
|
3809
|
+
*/
|
|
3810
|
+
async sendKey(key) {
|
|
3811
|
+
const args = {
|
|
3812
|
+
key
|
|
3813
|
+
};
|
|
3814
|
+
const result = await this.callMcpTool("send_key", args, "Failed to send key");
|
|
3815
|
+
return result.textContent || "";
|
|
3816
|
+
}
|
|
3817
|
+
/**
|
|
3818
|
+
* Inputs text into the active field.
|
|
3819
|
+
*
|
|
3820
|
+
* @param text - The text to input.
|
|
3821
|
+
* @returns The extracted text content from the API response
|
|
3822
|
+
* @throws Error if the operation fails.
|
|
3823
|
+
*/
|
|
3824
|
+
async inputText(text) {
|
|
3825
|
+
const args = {
|
|
3826
|
+
text
|
|
3827
|
+
};
|
|
3828
|
+
const result = await this.callMcpTool("input_text", args, "Failed to input text");
|
|
3829
|
+
return result.textContent || "";
|
|
3830
|
+
}
|
|
3831
|
+
/**
|
|
3832
|
+
* Performs a swipe gesture on the screen.
|
|
3833
|
+
*
|
|
3834
|
+
* @param startX - The starting X coordinate.
|
|
3835
|
+
* @param startY - The starting Y coordinate.
|
|
3836
|
+
* @param endX - The ending X coordinate.
|
|
3837
|
+
* @param endY - The ending Y coordinate.
|
|
3838
|
+
* @param durationMs - The duration of the swipe in milliseconds. Default is 300ms.
|
|
3839
|
+
* @returns The extracted text content from the API response
|
|
3840
|
+
* @throws Error if the operation fails.
|
|
3841
|
+
*/
|
|
3842
|
+
async swipe(startX, startY, endX, endY, durationMs = 300) {
|
|
3843
|
+
const args = {
|
|
3844
|
+
start_x: startX,
|
|
3845
|
+
start_y: startY,
|
|
3846
|
+
end_x: endX,
|
|
3847
|
+
end_y: endY,
|
|
3848
|
+
duration_ms: durationMs
|
|
3849
|
+
};
|
|
3850
|
+
const result = await this.callMcpTool("swipe", args, "Failed to perform swipe");
|
|
3851
|
+
return result.textContent || "";
|
|
3852
|
+
}
|
|
3853
|
+
/**
|
|
3854
|
+
* Performs a click at the specified coordinates.
|
|
3855
|
+
*
|
|
3856
|
+
* @param x - The X coordinate.
|
|
3857
|
+
* @param y - The Y coordinate.
|
|
3858
|
+
* @param button - The mouse button to click. Default is 'left'.
|
|
3859
|
+
* @returns The extracted text content from the API response
|
|
3860
|
+
* @throws Error if the operation fails.
|
|
3861
|
+
*/
|
|
3862
|
+
async click(x, y, button = "left") {
|
|
3863
|
+
const args = {
|
|
3864
|
+
x,
|
|
3865
|
+
y,
|
|
3866
|
+
button
|
|
3867
|
+
};
|
|
3868
|
+
const result = await this.callMcpTool("click", args, "Failed to perform click");
|
|
3869
|
+
return result.textContent || "";
|
|
3870
|
+
}
|
|
3871
|
+
/**
|
|
3872
|
+
* Takes a screenshot of the current screen.
|
|
3873
|
+
*
|
|
3874
|
+
* @returns The extracted text content from the API response (usually a base64-encoded image)
|
|
3875
|
+
* @throws Error if the operation fails.
|
|
3876
|
+
*/
|
|
3877
|
+
async screenshot() {
|
|
3878
|
+
const args = {};
|
|
3879
|
+
const result = await this.callMcpTool("system_screenshot", args, "Failed to take screenshot");
|
|
3880
|
+
return result.textContent || "";
|
|
3881
|
+
}
|
|
3882
|
+
};
|
|
3883
|
+
__name(_UI, "UI");
|
|
3884
|
+
var UI = _UI;
|
|
3885
|
+
|
|
3886
|
+
// src/session.ts
|
|
3887
|
+
var _Session = class _Session {
|
|
3888
|
+
/**
|
|
3889
|
+
* Initialize a Session object.
|
|
3890
|
+
*
|
|
3891
|
+
* @param agentBay - The AgentBay instance that created this session.
|
|
3892
|
+
* @param sessionId - The ID of this session.
|
|
3893
|
+
*/
|
|
3894
|
+
constructor(agentBay, sessionId) {
|
|
3895
|
+
this.resourceUrl = "";
|
|
3896
|
+
this.agentBay = agentBay;
|
|
3897
|
+
this.sessionId = sessionId;
|
|
3898
|
+
this.client = agentBay.getClient();
|
|
3899
|
+
log(`Session created with ID: ${sessionId}`);
|
|
3900
|
+
this.filesystem = new FileSystem(this);
|
|
3901
|
+
this.command = new Command(this);
|
|
3902
|
+
this.oss = new Oss(this);
|
|
3903
|
+
this.Application = new Application(this);
|
|
3904
|
+
this.window = new WindowManager(this);
|
|
3905
|
+
this.ui = new UI(this);
|
|
3906
|
+
}
|
|
3907
|
+
/**
|
|
3908
|
+
* Get information about this session.
|
|
3909
|
+
*
|
|
3910
|
+
* @returns Session information.
|
|
3911
|
+
*/
|
|
3912
|
+
// async get_info(): Promise<Record<string, any>> {
|
|
3913
|
+
// // TODO: Implement the API call to get session info
|
|
3914
|
+
// try {
|
|
3915
|
+
// const response = await this.client.get(this.baseUrl);
|
|
3916
|
+
// return response.data;
|
|
3917
|
+
// } catch (error) {
|
|
3918
|
+
// throw new APIError(`Failed to get session info: ${error}`);
|
|
3919
|
+
// }
|
|
3920
|
+
// }
|
|
3921
|
+
/**
|
|
3922
|
+
* Delete this session.
|
|
3923
|
+
*
|
|
3924
|
+
* @returns True if the session was successfully deleted.
|
|
3925
|
+
*/
|
|
3926
|
+
async delete() {
|
|
3927
|
+
try {
|
|
3928
|
+
const releaseSessionRequest = new ReleaseMcpSessionRequest({
|
|
3929
|
+
authorization: `Bearer ${this.getAPIKey()}`,
|
|
3930
|
+
sessionId: this.sessionId
|
|
3931
|
+
});
|
|
3932
|
+
console.log("API Call delete: ReleaseMcpSession", this.sessionId);
|
|
3933
|
+
log("API Call: ReleaseMcpSession");
|
|
3934
|
+
log(`Request: SessionId=${this.sessionId}`);
|
|
3935
|
+
const response = await this.client.releaseMcpSession(releaseSessionRequest);
|
|
3936
|
+
log(`Response from ReleaseMcpSession:`, response.body);
|
|
3937
|
+
this.agentBay.removeSession(this.sessionId);
|
|
3938
|
+
return true;
|
|
3939
|
+
} catch (error) {
|
|
3940
|
+
logError("Error calling ReleaseMcpSession:", error);
|
|
3941
|
+
throw new APIError(`Failed to delete session: ${error}`);
|
|
3942
|
+
}
|
|
3943
|
+
}
|
|
3944
|
+
/**
|
|
3945
|
+
* Sets the labels for this session.
|
|
3946
|
+
*
|
|
3947
|
+
* @param labels - The labels to set for the session.
|
|
3948
|
+
* @throws APIError if the operation fails.
|
|
3949
|
+
*/
|
|
3950
|
+
async setLabels(labels) {
|
|
3951
|
+
try {
|
|
3952
|
+
const labelsJSON = JSON.stringify(labels);
|
|
3953
|
+
const request = new SetLabelRequest({
|
|
3954
|
+
authorization: `Bearer ${this.getAPIKey()}`,
|
|
3955
|
+
sessionId: this.sessionId,
|
|
3956
|
+
labels: labelsJSON
|
|
3957
|
+
});
|
|
3958
|
+
log("API Call: SetLabel");
|
|
3959
|
+
log(`Request: SessionId=${this.sessionId}, Labels=${labelsJSON}`);
|
|
3960
|
+
const response = await this.client.setLabel(request);
|
|
3961
|
+
log(`Response from SetLabel:`, response.body);
|
|
3962
|
+
} catch (error) {
|
|
3963
|
+
logError("Error calling SetLabel:", error);
|
|
3964
|
+
throw new APIError(`Failed to set labels for session: ${error}`);
|
|
3965
|
+
}
|
|
3966
|
+
}
|
|
3967
|
+
/**
|
|
3968
|
+
* Gets the labels for this session.
|
|
3969
|
+
*
|
|
3970
|
+
* @returns The labels for the session.
|
|
3971
|
+
* @throws APIError if the operation fails.
|
|
3972
|
+
*/
|
|
3973
|
+
async getLabels() {
|
|
3974
|
+
try {
|
|
3975
|
+
const request = new GetLabelRequest({
|
|
3976
|
+
authorization: `Bearer ${this.getAPIKey()}`,
|
|
3977
|
+
sessionId: this.sessionId
|
|
3978
|
+
});
|
|
3979
|
+
log("API Call: GetLabel");
|
|
3980
|
+
log(`Request: SessionId=${this.sessionId}`);
|
|
3981
|
+
const response = await this.client.getLabel(request);
|
|
3982
|
+
console.log(`Response from GetLabel: ${JSON.stringify(response)}`);
|
|
3983
|
+
log(`Response from GetLabel:`, response.body);
|
|
3984
|
+
const labelsJSON = _optionalChain([response, 'access', _27 => _27.body, 'optionalAccess', _28 => _28.data, 'optionalAccess', _29 => _29.labels]);
|
|
3985
|
+
if (labelsJSON) {
|
|
3986
|
+
return JSON.parse(labelsJSON);
|
|
3987
|
+
}
|
|
3988
|
+
return {};
|
|
3989
|
+
} catch (error) {
|
|
3990
|
+
logError("Error calling GetLabel:", error);
|
|
3991
|
+
throw new APIError(`Failed to get labels for session: ${error}`);
|
|
3992
|
+
}
|
|
3993
|
+
}
|
|
3994
|
+
/**
|
|
3995
|
+
* Get the API key.
|
|
3996
|
+
*
|
|
3997
|
+
* @returns The API key.
|
|
3998
|
+
*/
|
|
3999
|
+
getAPIKey() {
|
|
4000
|
+
return this.agentBay.getAPIKey();
|
|
4001
|
+
}
|
|
4002
|
+
/**
|
|
4003
|
+
* Get the client.
|
|
4004
|
+
*
|
|
4005
|
+
* @returns The client.
|
|
4006
|
+
*/
|
|
4007
|
+
getClient() {
|
|
4008
|
+
return this.client;
|
|
4009
|
+
}
|
|
4010
|
+
/**
|
|
4011
|
+
* Get the session ID.
|
|
4012
|
+
*
|
|
4013
|
+
* @returns The session ID.
|
|
4014
|
+
*/
|
|
4015
|
+
getSessionId() {
|
|
4016
|
+
return this.sessionId;
|
|
4017
|
+
}
|
|
4018
|
+
/**
|
|
4019
|
+
* Gets information about this session.
|
|
4020
|
+
*
|
|
4021
|
+
* @returns Information about the session.
|
|
4022
|
+
* @throws APIError if the operation fails.
|
|
4023
|
+
*/
|
|
4024
|
+
async info() {
|
|
4025
|
+
try {
|
|
4026
|
+
const request = new GetMcpResourceRequest({
|
|
4027
|
+
authorization: `Bearer ${this.getAPIKey()}`,
|
|
4028
|
+
sessionId: this.sessionId
|
|
4029
|
+
});
|
|
4030
|
+
log("API Call: GetMcpResource");
|
|
4031
|
+
log(`Request: SessionId=${this.sessionId}`);
|
|
4032
|
+
const response = await this.client.getMcpResource(request);
|
|
4033
|
+
log(`Response from GetMcpResource:`, response.body);
|
|
4034
|
+
const sessionInfo = {
|
|
4035
|
+
sessionId: _optionalChain([response, 'access', _30 => _30.body, 'optionalAccess', _31 => _31.data, 'optionalAccess', _32 => _32.sessionId]) || "",
|
|
4036
|
+
resourceUrl: _optionalChain([response, 'access', _33 => _33.body, 'optionalAccess', _34 => _34.data, 'optionalAccess', _35 => _35.resourceUrl]) || ""
|
|
4037
|
+
};
|
|
4038
|
+
if (_optionalChain([response, 'access', _36 => _36.body, 'optionalAccess', _37 => _37.data, 'optionalAccess', _38 => _38.resourceUrl])) {
|
|
4039
|
+
this.resourceUrl = response.body.data.resourceUrl;
|
|
4040
|
+
}
|
|
4041
|
+
if (_optionalChain([response, 'access', _39 => _39.body, 'optionalAccess', _40 => _40.data, 'optionalAccess', _41 => _41.desktopInfo])) {
|
|
4042
|
+
const desktopInfo = response.body.data.desktopInfo;
|
|
4043
|
+
sessionInfo.appId = desktopInfo.appId;
|
|
4044
|
+
sessionInfo.authCode = desktopInfo.authCode;
|
|
4045
|
+
sessionInfo.connectionProperties = desktopInfo.connectionProperties;
|
|
4046
|
+
sessionInfo.resourceId = desktopInfo.resourceId;
|
|
4047
|
+
sessionInfo.resourceType = desktopInfo.resourceType;
|
|
4048
|
+
}
|
|
4049
|
+
return sessionInfo;
|
|
4050
|
+
} catch (error) {
|
|
4051
|
+
logError("Error calling GetMcpResource:", error);
|
|
4052
|
+
throw new APIError(`Failed to get session info for session ${this.sessionId}: ${error}`);
|
|
4053
|
+
}
|
|
4054
|
+
}
|
|
4055
|
+
/**
|
|
4056
|
+
* Gets the link for this session.
|
|
4057
|
+
*
|
|
4058
|
+
* @returns The link for the session.
|
|
4059
|
+
* @throws APIError if the operation fails.
|
|
4060
|
+
*/
|
|
4061
|
+
async getLink() {
|
|
4062
|
+
try {
|
|
4063
|
+
const request = new GetLinkRequest({
|
|
4064
|
+
authorization: `Bearer ${this.getAPIKey()}`,
|
|
4065
|
+
sessionId: this.sessionId
|
|
4066
|
+
});
|
|
4067
|
+
log("API Call: GetLink");
|
|
4068
|
+
log(`Request: SessionId=${this.sessionId}`);
|
|
4069
|
+
const response = await this.client.getLink(request);
|
|
4070
|
+
log(`Response from GetLink:`, response.body);
|
|
4071
|
+
if (_optionalChain([response, 'access', _42 => _42.body, 'optionalAccess', _43 => _43.data])) {
|
|
4072
|
+
return response.body.data;
|
|
4073
|
+
}
|
|
4074
|
+
return "";
|
|
4075
|
+
} catch (error) {
|
|
4076
|
+
logError("Error calling GetLink:", error);
|
|
4077
|
+
throw new APIError(`Failed to get link for session ${this.sessionId}: ${error}`);
|
|
4078
|
+
}
|
|
4079
|
+
}
|
|
4080
|
+
};
|
|
4081
|
+
__name(_Session, "Session");
|
|
4082
|
+
var Session = _Session;
|
|
4083
|
+
|
|
4084
|
+
// src/context.ts
|
|
4085
|
+
init_cjs_shims();
|
|
4086
|
+
var _Context = class _Context {
|
|
4087
|
+
/**
|
|
4088
|
+
* Initialize a Context object.
|
|
4089
|
+
*
|
|
4090
|
+
* @param id - The unique identifier of the context.
|
|
4091
|
+
* @param name - The name of the context.
|
|
4092
|
+
* @param state - The current state of the context.
|
|
4093
|
+
* @param createdAt - Date and time when the Context was created.
|
|
4094
|
+
* @param lastUsedAt - Date and time when the Context was last used.
|
|
4095
|
+
* @param osType - The operating system type this context is bound to.
|
|
4096
|
+
*/
|
|
4097
|
+
constructor(id, name, state = "available", createdAt, lastUsedAt, osType) {
|
|
4098
|
+
this.id = id;
|
|
4099
|
+
this.name = name;
|
|
4100
|
+
this.state = state;
|
|
4101
|
+
this.createdAt = createdAt;
|
|
4102
|
+
this.lastUsedAt = lastUsedAt;
|
|
4103
|
+
this.osType = osType;
|
|
4104
|
+
}
|
|
4105
|
+
};
|
|
4106
|
+
__name(_Context, "Context");
|
|
4107
|
+
var Context = _Context;
|
|
4108
|
+
var _ContextService = class _ContextService {
|
|
4109
|
+
/**
|
|
4110
|
+
* Initialize the ContextService.
|
|
4111
|
+
*
|
|
4112
|
+
* @param agentBay - The AgentBay instance.
|
|
4113
|
+
*/
|
|
4114
|
+
constructor(agentBay) {
|
|
4115
|
+
this.agentBay = agentBay;
|
|
4116
|
+
}
|
|
4117
|
+
/**
|
|
4118
|
+
* Lists all available contexts.
|
|
4119
|
+
*
|
|
4120
|
+
* @returns A list of Context objects.
|
|
4121
|
+
*/
|
|
4122
|
+
async list() {
|
|
4123
|
+
try {
|
|
4124
|
+
const request = new ListContextsRequest({
|
|
4125
|
+
authorization: `Bearer ${this.agentBay.getAPIKey()}`
|
|
4126
|
+
});
|
|
4127
|
+
log("API Call: ListContexts");
|
|
4128
|
+
log("Request: No parameters");
|
|
4129
|
+
const response = await this.agentBay.getClient().listContexts(request);
|
|
4130
|
+
log(`Response from ListContexts:`, response.body);
|
|
4131
|
+
const contexts = [];
|
|
4132
|
+
if (_optionalChain([response, 'access', _44 => _44.body, 'optionalAccess', _45 => _45.data])) {
|
|
4133
|
+
for (const contextData of response.body.data) {
|
|
4134
|
+
contexts.push(new Context(
|
|
4135
|
+
contextData.id || "",
|
|
4136
|
+
contextData.name || "",
|
|
4137
|
+
contextData.state || "available",
|
|
4138
|
+
contextData.createTime,
|
|
4139
|
+
contextData.lastUsedTime,
|
|
4140
|
+
contextData.osType
|
|
4141
|
+
));
|
|
4142
|
+
}
|
|
4143
|
+
}
|
|
4144
|
+
return contexts;
|
|
4145
|
+
} catch (error) {
|
|
4146
|
+
logError("Error calling ListContexts:", error);
|
|
4147
|
+
throw new APIError(`Failed to list contexts: ${error}`);
|
|
4148
|
+
}
|
|
4149
|
+
}
|
|
4150
|
+
/**
|
|
4151
|
+
* Gets a context by name. Optionally creates it if it doesn't exist.
|
|
4152
|
+
*
|
|
4153
|
+
* @param name - The name of the context to get.
|
|
4154
|
+
* @param create - Whether to create the context if it doesn't exist.
|
|
4155
|
+
* @returns The Context object if found or created, null if not found and create is false.
|
|
4156
|
+
*/
|
|
4157
|
+
async get(name, create = false) {
|
|
4158
|
+
try {
|
|
4159
|
+
const request = new GetContextRequest({
|
|
4160
|
+
name,
|
|
4161
|
+
allowCreate: create ? "true" : "false",
|
|
4162
|
+
authorization: `Bearer ${this.agentBay.getAPIKey()}`
|
|
4163
|
+
});
|
|
4164
|
+
log("API Call: GetContext");
|
|
4165
|
+
log(`Request: Name=${name}, AllowCreate=${create}`);
|
|
4166
|
+
const response = await this.agentBay.getClient().getContext(request);
|
|
4167
|
+
log(`Response from GetContext:`, response.body);
|
|
4168
|
+
const contextId = _optionalChain([response, 'access', _46 => _46.body, 'optionalAccess', _47 => _47.data, 'optionalAccess', _48 => _48.id]);
|
|
4169
|
+
if (!contextId) {
|
|
4170
|
+
return null;
|
|
4171
|
+
}
|
|
4172
|
+
const contexts = await this.list();
|
|
4173
|
+
for (const context of contexts) {
|
|
4174
|
+
if (context.id === contextId) {
|
|
4175
|
+
return context;
|
|
4176
|
+
}
|
|
4177
|
+
}
|
|
4178
|
+
return new Context(contextId, name);
|
|
4179
|
+
} catch (error) {
|
|
4180
|
+
logError("Error calling GetContext:", error);
|
|
4181
|
+
throw new APIError(`Failed to get context ${name}: ${error}`);
|
|
4182
|
+
}
|
|
4183
|
+
}
|
|
4184
|
+
/**
|
|
4185
|
+
* Creates a new context with the given name.
|
|
4186
|
+
*
|
|
4187
|
+
* @param name - The name for the new context.
|
|
4188
|
+
* @returns The created Context object.
|
|
4189
|
+
*/
|
|
4190
|
+
async create(name) {
|
|
4191
|
+
const context = await this.get(name, true);
|
|
4192
|
+
if (!context) {
|
|
4193
|
+
throw new APIError(`Failed to create context ${name}`);
|
|
4194
|
+
}
|
|
4195
|
+
return context;
|
|
4196
|
+
}
|
|
4197
|
+
/**
|
|
4198
|
+
* Updates the specified context.
|
|
4199
|
+
*
|
|
4200
|
+
* @param context - The Context object to update.
|
|
4201
|
+
* @returns The updated Context object.
|
|
4202
|
+
*/
|
|
4203
|
+
async update(context) {
|
|
4204
|
+
try {
|
|
4205
|
+
const request = new ModifyContextRequest({
|
|
4206
|
+
id: context.id,
|
|
4207
|
+
name: context.name,
|
|
4208
|
+
authorization: `Bearer ${this.agentBay.getAPIKey()}`
|
|
4209
|
+
});
|
|
4210
|
+
log("API Call: ModifyContext");
|
|
4211
|
+
log(`Request: Id=${context.id}, Name=${context.name}`);
|
|
4212
|
+
const response = await this.agentBay.getClient().modifyContext(request);
|
|
4213
|
+
log(`Response from ModifyContext:`, response.body);
|
|
4214
|
+
return context;
|
|
4215
|
+
} catch (error) {
|
|
4216
|
+
logError("Error calling ModifyContext:", error);
|
|
4217
|
+
throw new APIError(`Failed to update context ${context.id}: ${error}`);
|
|
4218
|
+
}
|
|
4219
|
+
}
|
|
4220
|
+
/**
|
|
4221
|
+
* Deletes the specified context.
|
|
4222
|
+
*
|
|
4223
|
+
* @param context - The Context object to delete.
|
|
4224
|
+
*/
|
|
4225
|
+
async delete(context) {
|
|
4226
|
+
try {
|
|
4227
|
+
const request = new DeleteContextRequest({
|
|
4228
|
+
id: context.id,
|
|
4229
|
+
authorization: `Bearer ${this.agentBay.getAPIKey()}`
|
|
4230
|
+
});
|
|
4231
|
+
log("API Call: DeleteContext");
|
|
4232
|
+
log(`Request: Id=${context.id}`);
|
|
4233
|
+
const response = await this.agentBay.getClient().deleteContext(request);
|
|
4234
|
+
log(`Response from DeleteContext:`, response.body);
|
|
4235
|
+
} catch (error) {
|
|
4236
|
+
logError("Error calling DeleteContext:", error);
|
|
4237
|
+
throw new APIError(`Failed to delete context ${context.id}: ${error}`);
|
|
4238
|
+
}
|
|
4239
|
+
}
|
|
4240
|
+
};
|
|
4241
|
+
__name(_ContextService, "ContextService");
|
|
4242
|
+
var ContextService = _ContextService;
|
|
4243
|
+
|
|
4244
|
+
// src/agent-bay.ts
|
|
4245
|
+
|
|
4246
|
+
|
|
4247
|
+
// src/config.ts
|
|
4248
|
+
init_cjs_shims();
|
|
4249
|
+
var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
|
|
4250
|
+
var _path = require('path'); var path = _interopRequireWildcard(_path);
|
|
4251
|
+
|
|
4252
|
+
// node_modules/dotenv/config.js
|
|
4253
|
+
init_cjs_shims();
|
|
4254
|
+
(function() {
|
|
4255
|
+
require_main().config(
|
|
4256
|
+
Object.assign(
|
|
4257
|
+
{},
|
|
4258
|
+
require_env_options(),
|
|
4259
|
+
require_cli_options()(process.argv)
|
|
4260
|
+
)
|
|
4261
|
+
);
|
|
4262
|
+
})();
|
|
4263
|
+
|
|
4264
|
+
// src/config.ts
|
|
4265
|
+
function defaultConfig() {
|
|
4266
|
+
return {
|
|
4267
|
+
region_id: "cn-shanghai",
|
|
4268
|
+
endpoint: "wuyingai.cn-shanghai.aliyuncs.com",
|
|
4269
|
+
timeout_ms: 3e5
|
|
4270
|
+
};
|
|
4271
|
+
}
|
|
4272
|
+
__name(defaultConfig, "defaultConfig");
|
|
4273
|
+
function loadConfig() {
|
|
4274
|
+
let configPath = process.env.AGENTBAY_CONFIG_PATH;
|
|
4275
|
+
if (!configPath) {
|
|
4276
|
+
try {
|
|
4277
|
+
let dirPath = process.cwd();
|
|
4278
|
+
let found = false;
|
|
4279
|
+
for (let i = 0; i < 10; i++) {
|
|
4280
|
+
const possibleConfigPath = path.join(dirPath, ".config.json");
|
|
4281
|
+
if (fs.existsSync(possibleConfigPath)) {
|
|
4282
|
+
configPath = possibleConfigPath;
|
|
4283
|
+
found = true;
|
|
4284
|
+
log(`Found config file at: ${possibleConfigPath}`);
|
|
4285
|
+
break;
|
|
4286
|
+
}
|
|
4287
|
+
const parentDir = path.dirname(dirPath);
|
|
4288
|
+
if (parentDir === dirPath) {
|
|
4289
|
+
break;
|
|
4290
|
+
}
|
|
4291
|
+
dirPath = parentDir;
|
|
4292
|
+
}
|
|
4293
|
+
if (!found) {
|
|
4294
|
+
log("Warning: Configuration file not found, using default values");
|
|
4295
|
+
return defaultConfig();
|
|
4296
|
+
}
|
|
4297
|
+
} catch (error) {
|
|
4298
|
+
log(`Warning: Failed to search for configuration file: ${error}, using default values`);
|
|
4299
|
+
return defaultConfig();
|
|
4300
|
+
}
|
|
4301
|
+
}
|
|
4302
|
+
try {
|
|
4303
|
+
if (!configPath) {
|
|
4304
|
+
log("Warning: Configuration file path is undefined, using default values");
|
|
4305
|
+
return defaultConfig();
|
|
4306
|
+
}
|
|
4307
|
+
const data = fs.readFileSync(configPath, "utf8");
|
|
4308
|
+
const config = JSON.parse(data);
|
|
4309
|
+
if (process.env.AGENTBAY_REGION_ID) {
|
|
4310
|
+
config.region_id = process.env.AGENTBAY_REGION_ID;
|
|
4311
|
+
}
|
|
4312
|
+
if (process.env.AGENTBAY_ENDPOINT) {
|
|
4313
|
+
config.endpoint = process.env.AGENTBAY_ENDPOINT;
|
|
4314
|
+
}
|
|
4315
|
+
return config;
|
|
4316
|
+
} catch (error) {
|
|
4317
|
+
log(`Warning: Failed to read configuration file: ${error}, using default values`);
|
|
4318
|
+
return defaultConfig();
|
|
4319
|
+
}
|
|
4320
|
+
}
|
|
4321
|
+
__name(loadConfig, "loadConfig");
|
|
4322
|
+
|
|
4323
|
+
// src/agent-bay.ts
|
|
4324
|
+
var _AgentBay = class _AgentBay {
|
|
4325
|
+
/**
|
|
4326
|
+
* Initialize the AgentBay client.
|
|
4327
|
+
*
|
|
4328
|
+
* @param options - Configuration options
|
|
4329
|
+
* @param options.apiKey - API key for authentication. If not provided, will look for AGENTBAY_API_KEY environment variable.
|
|
4330
|
+
*/
|
|
4331
|
+
constructor(options = {}) {
|
|
4332
|
+
this.sessions = /* @__PURE__ */ new Map();
|
|
4333
|
+
this.apiKey = options.apiKey || process.env.AGENTBAY_API_KEY || "";
|
|
4334
|
+
if (!this.apiKey) {
|
|
4335
|
+
throw new AuthenticationError(
|
|
4336
|
+
"API key is required. Provide it as a parameter or set the AGENTBAY_API_KEY environment variable."
|
|
4337
|
+
);
|
|
4338
|
+
}
|
|
4339
|
+
const configData = loadConfig();
|
|
4340
|
+
this.regionId = configData.region_id;
|
|
4341
|
+
this.endpoint = configData.endpoint;
|
|
4342
|
+
const config = new _openapicore.$OpenApiUtil.Config({
|
|
4343
|
+
regionId: this.regionId,
|
|
4344
|
+
endpoint: this.endpoint
|
|
4345
|
+
});
|
|
4346
|
+
config.readTimeout = configData.timeout_ms;
|
|
4347
|
+
config.connectTimeout = configData.timeout_ms;
|
|
4348
|
+
try {
|
|
4349
|
+
this.client = new Client(config);
|
|
4350
|
+
this.context = new ContextService(this);
|
|
4351
|
+
} catch (error) {
|
|
4352
|
+
logError(`Failed to constructor:`, error);
|
|
4353
|
+
throw new AuthenticationError(`Failed to constructor: ${error}`);
|
|
4354
|
+
}
|
|
4355
|
+
}
|
|
4356
|
+
/**
|
|
4357
|
+
* Create a new session in the AgentBay cloud environment.
|
|
4358
|
+
*
|
|
4359
|
+
* @param options - Optional parameters for creating the session
|
|
4360
|
+
* @param options.contextId - ID of the context to bind to the session
|
|
4361
|
+
* @param options.labels - Custom labels for the session
|
|
4362
|
+
* @returns A new Session object.
|
|
4363
|
+
*/
|
|
4364
|
+
async create(options = {}) {
|
|
4365
|
+
try {
|
|
4366
|
+
const createSessionRequest = new CreateMcpSessionRequest({
|
|
4367
|
+
authorization: "Bearer " + this.apiKey,
|
|
4368
|
+
imageId: options.imageId
|
|
4369
|
+
});
|
|
4370
|
+
if (options.contextId) {
|
|
4371
|
+
createSessionRequest.contextId = options.contextId;
|
|
4372
|
+
}
|
|
4373
|
+
if (options.labels) {
|
|
4374
|
+
createSessionRequest.labels = JSON.stringify(options.labels);
|
|
4375
|
+
}
|
|
4376
|
+
log("API Call: CreateMcpSession");
|
|
4377
|
+
log(`Request: ${options.contextId ? `ContextId=${options.contextId}, ` : ""}${options.labels ? `Labels=${JSON.stringify(options.labels)}, ` : ""}${options.imageId ? `ImageId=${options.imageId}` : ""}`);
|
|
4378
|
+
const response = await this.client.createMcpSession(createSessionRequest);
|
|
4379
|
+
log(`Response from CreateMcpSession:`, response.body);
|
|
4380
|
+
const sessionId = _optionalChain([response, 'access', _49 => _49.body, 'optionalAccess', _50 => _50.data, 'optionalAccess', _51 => _51.sessionId]);
|
|
4381
|
+
if (!sessionId) {
|
|
4382
|
+
throw new APIError("Invalid session ID in response");
|
|
4383
|
+
}
|
|
4384
|
+
const resourceUrl = _optionalChain([response, 'access', _52 => _52.body, 'optionalAccess', _53 => _53.data, 'optionalAccess', _54 => _54.resourceUrl]);
|
|
4385
|
+
const session = new Session(this, sessionId);
|
|
4386
|
+
if (resourceUrl) {
|
|
4387
|
+
session.resourceUrl = resourceUrl;
|
|
4388
|
+
}
|
|
4389
|
+
this.sessions.set(session.sessionId, session);
|
|
4390
|
+
return session;
|
|
4391
|
+
} catch (error) {
|
|
4392
|
+
logError("Error calling CreateMcpSession:", error);
|
|
4393
|
+
throw new APIError(`Failed to create session: ${error}`);
|
|
4394
|
+
}
|
|
4395
|
+
}
|
|
4396
|
+
/**
|
|
4397
|
+
* List all available sessions.
|
|
4398
|
+
*
|
|
4399
|
+
* @returns A list of session objects.
|
|
4400
|
+
*/
|
|
4401
|
+
list() {
|
|
4402
|
+
return Array.from(this.sessions.values());
|
|
4403
|
+
}
|
|
4404
|
+
/**
|
|
4405
|
+
* List sessions filtered by the provided labels.
|
|
4406
|
+
* It returns sessions that match all the specified labels.
|
|
4407
|
+
*
|
|
4408
|
+
* @param labels - The labels to filter by.
|
|
4409
|
+
* @returns A list of session objects that match the labels.
|
|
4410
|
+
*/
|
|
4411
|
+
async listByLabels(labels) {
|
|
4412
|
+
try {
|
|
4413
|
+
const labelsJSON = JSON.stringify(labels);
|
|
4414
|
+
const listSessionRequest = new ListSessionRequest({
|
|
4415
|
+
authorization: `Bearer ${this.apiKey}`,
|
|
4416
|
+
labels: labelsJSON
|
|
4417
|
+
});
|
|
4418
|
+
log("API Call: ListSession");
|
|
4419
|
+
log(`Request: Labels=${labelsJSON}`);
|
|
4420
|
+
const response = await this.client.listSession(listSessionRequest);
|
|
4421
|
+
log(`Response from ListSession:`, response.body);
|
|
4422
|
+
const sessions = [];
|
|
4423
|
+
if (_optionalChain([response, 'access', _55 => _55.body, 'optionalAccess', _56 => _56.data])) {
|
|
4424
|
+
for (const sessionData of response.body.data) {
|
|
4425
|
+
if (sessionData.sessionId) {
|
|
4426
|
+
const session = new Session(this, sessionData.sessionId);
|
|
4427
|
+
sessions.push(session);
|
|
4428
|
+
this.sessions.set(sessionData.sessionId, session);
|
|
4429
|
+
}
|
|
4430
|
+
}
|
|
4431
|
+
}
|
|
4432
|
+
return sessions;
|
|
4433
|
+
} catch (error) {
|
|
4434
|
+
logError("Error calling ListSession:", error);
|
|
4435
|
+
throw new APIError(`Failed to list sessions by labels: ${error}`);
|
|
4436
|
+
}
|
|
4437
|
+
}
|
|
4438
|
+
/**
|
|
4439
|
+
* Delete a session by ID.
|
|
4440
|
+
*
|
|
4441
|
+
* @param sessionId - The ID of the session to delete.
|
|
4442
|
+
* @returns True if the session was successfully deleted.
|
|
4443
|
+
*/
|
|
4444
|
+
async delete(session) {
|
|
4445
|
+
const getSession = this.sessions.get(session.sessionId);
|
|
4446
|
+
if (!getSession) {
|
|
4447
|
+
throw new Error(`Session with ID ${session.sessionId} not found`);
|
|
4448
|
+
}
|
|
4449
|
+
try {
|
|
4450
|
+
await session.delete();
|
|
4451
|
+
return true;
|
|
4452
|
+
} catch (error) {
|
|
4453
|
+
throw new APIError(`Failed to delete session: ${error}`);
|
|
4454
|
+
}
|
|
4455
|
+
}
|
|
4456
|
+
/**
|
|
4457
|
+
*
|
|
4458
|
+
* @param sessionId - The ID of the session to remove.
|
|
4459
|
+
*/
|
|
4460
|
+
removeSession(sessionId) {
|
|
4461
|
+
this.sessions.delete(sessionId);
|
|
4462
|
+
}
|
|
4463
|
+
// For internal use by the Session class
|
|
4464
|
+
getClient() {
|
|
4465
|
+
return this.client;
|
|
4466
|
+
}
|
|
4467
|
+
getAPIKey() {
|
|
4468
|
+
return this.apiKey;
|
|
4469
|
+
}
|
|
4470
|
+
};
|
|
4471
|
+
__name(_AgentBay, "AgentBay");
|
|
4472
|
+
var AgentBay = _AgentBay;
|
|
4473
|
+
|
|
4474
|
+
|
|
4475
|
+
|
|
4476
|
+
|
|
4477
|
+
|
|
4478
|
+
|
|
4479
|
+
|
|
4480
|
+
|
|
4481
|
+
|
|
4482
|
+
|
|
4483
|
+
|
|
4484
|
+
|
|
4485
|
+
|
|
4486
|
+
|
|
4487
|
+
|
|
4488
|
+
|
|
4489
|
+
|
|
4490
|
+
|
|
4491
|
+
|
|
4492
|
+
|
|
4493
|
+
|
|
4494
|
+
|
|
4495
|
+
|
|
4496
|
+
|
|
4497
|
+
|
|
4498
|
+
|
|
4499
|
+
|
|
4500
|
+
|
|
4501
|
+
|
|
4502
|
+
|
|
4503
|
+
|
|
4504
|
+
|
|
4505
|
+
|
|
4506
|
+
|
|
4507
|
+
|
|
4508
|
+
|
|
4509
|
+
|
|
4510
|
+
|
|
4511
|
+
|
|
4512
|
+
|
|
4513
|
+
|
|
4514
|
+
|
|
4515
|
+
|
|
4516
|
+
|
|
4517
|
+
|
|
4518
|
+
|
|
4519
|
+
|
|
4520
|
+
|
|
4521
|
+
|
|
4522
|
+
|
|
4523
|
+
|
|
4524
|
+
|
|
4525
|
+
|
|
4526
|
+
|
|
4527
|
+
|
|
4528
|
+
|
|
4529
|
+
|
|
4530
|
+
|
|
4531
|
+
|
|
4532
|
+
|
|
4533
|
+
exports.APIError = APIError; exports.AgentBay = AgentBay; exports.AgentBayError = AgentBayError; exports.Application = Application; exports.AuthenticationError = AuthenticationError; exports.CallMcpToolRequest = CallMcpToolRequest; exports.CallMcpToolResponse = CallMcpToolResponse; exports.CallMcpToolResponseBody = CallMcpToolResponseBody; exports.Client = Client; exports.Command = Command; exports.CommandError = CommandError; exports.Context = Context; exports.ContextService = ContextService; exports.CreateMcpSessionRequest = CreateMcpSessionRequest; exports.CreateMcpSessionResponse = CreateMcpSessionResponse; exports.CreateMcpSessionResponseBody = CreateMcpSessionResponseBody; exports.CreateMcpSessionResponseBodyData = CreateMcpSessionResponseBodyData; exports.DeleteContextRequest = DeleteContextRequest; exports.DeleteContextResponse = DeleteContextResponse; exports.DeleteContextResponseBody = DeleteContextResponseBody; exports.FileError = FileError; exports.FileSystem = FileSystem; exports.GetContextRequest = GetContextRequest; exports.GetContextResponse = GetContextResponse; exports.GetContextResponseBody = GetContextResponseBody; exports.GetContextResponseBodyData = GetContextResponseBodyData; exports.GetLabelRequest = GetLabelRequest; exports.GetLabelResponse = GetLabelResponse; exports.GetLabelResponseBody = GetLabelResponseBody; exports.GetLabelResponseBodyData = GetLabelResponseBodyData; exports.GetLinkRequest = GetLinkRequest; exports.GetLinkResponse = GetLinkResponse; exports.GetLinkResponseBody = GetLinkResponseBody; exports.GetMcpResourceRequest = GetMcpResourceRequest; exports.GetMcpResourceResponse = GetMcpResourceResponse; exports.GetMcpResourceResponseBody = GetMcpResourceResponseBody; exports.GetMcpResourceResponseBodyData = GetMcpResourceResponseBodyData; exports.GetMcpResourceResponseBodyDataDesktopInfo = GetMcpResourceResponseBodyDataDesktopInfo; exports.KeyCode = KeyCode; exports.ListContextsRequest = ListContextsRequest; exports.ListContextsResponse = ListContextsResponse; exports.ListContextsResponseBody = ListContextsResponseBody; exports.ListContextsResponseBodyData = ListContextsResponseBodyData; exports.ListSessionRequest = ListSessionRequest; exports.ListSessionResponse = ListSessionResponse; exports.ListSessionResponseBody = ListSessionResponseBody; exports.ListSessionResponseBodyData = ListSessionResponseBodyData; exports.ModifyContextRequest = ModifyContextRequest; exports.ModifyContextResponse = ModifyContextResponse; exports.ModifyContextResponseBody = ModifyContextResponseBody; exports.Oss = Oss; exports.ReleaseMcpSessionRequest = ReleaseMcpSessionRequest; exports.ReleaseMcpSessionResponse = ReleaseMcpSessionResponse; exports.ReleaseMcpSessionResponseBody = ReleaseMcpSessionResponseBody; exports.Session = Session; exports.SetLabelRequest = SetLabelRequest; exports.SetLabelResponse = SetLabelResponse; exports.SetLabelResponseBody = SetLabelResponseBody; exports.UI = UI;
|
|
4534
|
+
//# sourceMappingURL=index.cjs.map
|