@aiscene/shared 8.0.2 → 8.0.4
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/dist/es/agent-tools/agent-behavior-init-args.mjs +44 -0
- package/dist/es/agent-tools/base-tools.mjs +163 -0
- package/dist/es/agent-tools/chrome-path.mjs +50 -0
- package/dist/es/agent-tools/cli-report-session.mjs +78 -0
- package/dist/es/agent-tools/error-formatter.mjs +106 -0
- package/dist/es/agent-tools/index.mjs +9 -0
- package/dist/es/agent-tools/init-arg-utils.mjs +38 -0
- package/dist/es/agent-tools/observation-artifact.mjs +5 -0
- package/dist/es/agent-tools/observation-record.mjs +248 -0
- package/dist/es/agent-tools/tool-defaults.mjs +54 -0
- package/dist/es/agent-tools/tool-generator.mjs +529 -0
- package/dist/es/agent-tools/types.mjs +3 -0
- package/dist/es/agent-tools/user-prompt.mjs +66 -0
- package/dist/es/cli/cli-args.mjs +95 -0
- package/dist/es/cli/cli-error.mjs +24 -0
- package/dist/es/cli/cli-runner.mjs +10 -40
- package/dist/es/cli/index.mjs +4 -2
- package/dist/es/cli/interrupt.mjs +116 -0
- package/dist/es/cli/record-command.mjs +130 -0
- package/dist/es/cli/screenshot-file.mjs +24 -0
- package/dist/es/cli/verbose-ai-act.mjs +230 -0
- package/dist/es/cli/verbose-screenshot.mjs +134 -0
- package/dist/es/cli/verbose.mjs +404 -0
- package/dist/es/constants/example-code.mjs +2 -2
- package/dist/es/constants/index.mjs +6 -1
- package/dist/es/env/model-config-manager.mjs +3 -0
- package/dist/es/env/parse-model-config.mjs +6 -1
- package/dist/es/env/types.mjs +4 -1
- package/dist/es/env/utils.mjs +1 -9
- package/dist/es/extractor/index.mjs +2 -2
- package/dist/es/img/index.mjs +2 -2
- package/dist/es/img/info.mjs +58 -17
- package/dist/es/img/photon-loader.mjs +4 -0
- package/dist/es/key-alias-utils.mjs +19 -0
- package/dist/es/mcp/base-server.mjs +10 -9
- package/dist/es/mcp/base-tools.mjs +72 -4
- package/dist/es/mcp/cli-report-session.mjs +78 -0
- package/dist/es/mcp/error-formatter.mjs +19 -0
- package/dist/es/mcp/index.mjs +2 -0
- package/dist/es/mcp/init-arg-utils.mjs +38 -0
- package/dist/es/mcp/inject-report-html-plugin.mjs +1 -1
- package/dist/es/mcp/tool-generator.mjs +65 -17
- package/dist/es/node/fs.mjs +1 -1
- package/dist/es/recorder.mjs +249 -0
- package/dist/lib/agent-tools/agent-behavior-init-args.js +87 -0
- package/dist/lib/agent-tools/base-tools.js +197 -0
- package/dist/lib/agent-tools/chrome-path.js +87 -0
- package/dist/lib/agent-tools/cli-report-session.js +121 -0
- package/dist/lib/agent-tools/error-formatter.js +149 -0
- package/dist/lib/agent-tools/index.js +114 -0
- package/dist/lib/agent-tools/init-arg-utils.js +78 -0
- package/dist/lib/agent-tools/observation-artifact.js +42 -0
- package/dist/lib/agent-tools/observation-record.js +297 -0
- package/dist/lib/agent-tools/tool-defaults.js +97 -0
- package/dist/lib/agent-tools/tool-generator.js +569 -0
- package/dist/lib/agent-tools/types.js +40 -0
- package/dist/lib/agent-tools/user-prompt.js +103 -0
- package/dist/lib/cli/cli-args.js +138 -0
- package/dist/lib/cli/cli-error.js +61 -0
- package/dist/lib/cli/cli-runner.js +19 -46
- package/dist/lib/cli/index.js +8 -3
- package/dist/lib/cli/interrupt.js +156 -0
- package/dist/lib/cli/record-command.js +164 -0
- package/dist/lib/cli/screenshot-file.js +58 -0
- package/dist/lib/cli/verbose-ai-act.js +273 -0
- package/dist/lib/cli/verbose-screenshot.js +177 -0
- package/dist/lib/cli/verbose.js +465 -0
- package/dist/lib/constants/example-code.js +2 -2
- package/dist/lib/constants/index.js +23 -3
- package/dist/lib/env/model-config-manager.js +3 -0
- package/dist/lib/env/parse-model-config.js +6 -1
- package/dist/lib/env/types.js +9 -0
- package/dist/lib/env/utils.js +0 -11
- package/dist/lib/extractor/index.js +3 -0
- package/dist/lib/img/index.js +3 -0
- package/dist/lib/img/info.js +65 -18
- package/dist/lib/img/photon-loader.js +38 -0
- package/dist/lib/key-alias-utils.js +62 -0
- package/dist/lib/mcp/base-server.js +11 -10
- package/dist/lib/mcp/base-tools.js +74 -6
- package/dist/lib/mcp/cli-report-session.js +121 -0
- package/dist/lib/mcp/error-formatter.js +53 -0
- package/dist/lib/mcp/index.js +24 -10
- package/dist/lib/mcp/init-arg-utils.js +78 -0
- package/dist/lib/mcp/inject-report-html-plugin.js +1 -1
- package/dist/lib/mcp/tool-generator.js +74 -26
- package/dist/lib/node/fs.js +1 -1
- package/dist/lib/recorder.js +307 -0
- package/dist/types/agent-tools/agent-behavior-init-args.d.ts +17 -0
- package/dist/types/agent-tools/base-tools.d.ts +158 -0
- package/dist/types/agent-tools/chrome-path.d.ts +2 -0
- package/dist/types/agent-tools/cli-report-session.d.ts +12 -0
- package/dist/types/agent-tools/error-formatter.d.ts +30 -0
- package/dist/types/agent-tools/index.d.ts +9 -0
- package/dist/types/agent-tools/init-arg-utils.d.ts +13 -0
- package/dist/types/agent-tools/observation-artifact.d.ts +10 -0
- package/dist/types/agent-tools/observation-record.d.ts +38 -0
- package/dist/types/agent-tools/tool-defaults.d.ts +63 -0
- package/dist/types/agent-tools/tool-generator.d.ts +13 -0
- package/dist/types/agent-tools/types.d.ts +213 -0
- package/dist/types/agent-tools/user-prompt.d.ts +13 -0
- package/dist/types/cli/cli-args.d.ts +8 -0
- package/dist/types/cli/cli-error.d.ts +5 -0
- package/dist/types/cli/cli-runner.d.ts +4 -7
- package/dist/types/cli/index.d.ts +3 -1
- package/dist/types/cli/interrupt.d.ts +49 -0
- package/dist/types/cli/record-command.d.ts +3 -0
- package/dist/types/cli/screenshot-file.d.ts +10 -0
- package/dist/types/cli/verbose-ai-act.d.ts +44 -0
- package/dist/types/cli/verbose-screenshot.d.ts +10 -0
- package/dist/types/cli/verbose.d.ts +40 -0
- package/dist/types/constants/example-code.d.ts +1 -1
- package/dist/types/constants/index.d.ts +5 -0
- package/dist/types/env/types.d.ts +14 -5
- package/dist/types/env/utils.d.ts +0 -31
- package/dist/types/extractor/index.d.ts +1 -1
- package/dist/types/img/index.d.ts +1 -1
- package/dist/types/img/info.d.ts +7 -0
- package/dist/types/img/photon-loader.d.ts +2 -0
- package/dist/types/key-alias-utils.d.ts +9 -0
- package/dist/types/mcp/base-tools.d.ts +74 -5
- package/dist/types/mcp/cli-report-session.d.ts +12 -0
- package/dist/types/mcp/error-formatter.d.ts +12 -0
- package/dist/types/mcp/index.d.ts +2 -0
- package/dist/types/mcp/init-arg-utils.d.ts +13 -0
- package/dist/types/mcp/inject-report-html-plugin.d.ts +2 -2
- package/dist/types/mcp/launcher-helper.d.ts +3 -3
- package/dist/types/mcp/tool-generator.d.ts +3 -3
- package/dist/types/mcp/types.d.ts +10 -0
- package/dist/types/recorder.d.ts +113 -0
- package/package.json +1 -1
- package/src/agent-tools/agent-behavior-init-args.ts +109 -0
- package/src/agent-tools/base-tools.ts +399 -0
- package/src/agent-tools/chrome-path.ts +74 -0
- package/src/agent-tools/cli-report-session.ts +130 -0
- package/src/agent-tools/error-formatter.ts +177 -0
- package/src/agent-tools/index.ts +9 -0
- package/src/agent-tools/init-arg-utils.ts +105 -0
- package/src/agent-tools/observation-artifact.ts +29 -0
- package/src/agent-tools/observation-record.ts +331 -0
- package/src/agent-tools/tool-defaults.ts +119 -0
- package/src/agent-tools/tool-generator.ts +866 -0
- package/src/agent-tools/types.ts +250 -0
- package/src/agent-tools/user-prompt.ts +102 -0
- package/src/cli/cli-args.ts +173 -0
- package/src/cli/cli-error.ts +24 -0
- package/src/cli/cli-runner.ts +37 -56
- package/src/cli/index.ts +3 -7
- package/src/cli/interrupt.ts +207 -0
- package/src/cli/record-command.ts +177 -0
- package/src/cli/screenshot-file.ts +61 -0
- package/src/cli/verbose-ai-act.ts +387 -0
- package/src/cli/verbose-screenshot.ts +269 -0
- package/src/cli/verbose.ts +753 -0
- package/src/constants/example-code.ts +2 -2
- package/src/constants/index.ts +10 -0
- package/src/env/model-config-manager.ts +3 -0
- package/src/env/parse-model-config.ts +19 -1
- package/src/env/types.ts +13 -2
- package/src/env/utils.ts +0 -50
- package/src/extractor/index.ts +1 -1
- package/src/img/index.ts +14 -0
- package/src/img/info.ts +97 -45
- package/src/img/photon-loader.ts +5 -0
- package/src/img/transform.ts +261 -2
- package/src/key-alias-utils.ts +23 -0
- package/src/mcp/base-server.ts +10 -12
- package/src/mcp/base-tools.ts +218 -11
- package/src/mcp/cli-report-session.ts +130 -0
- package/src/mcp/error-formatter.ts +52 -0
- package/src/mcp/index.ts +2 -0
- package/src/mcp/init-arg-utils.ts +105 -0
- package/src/mcp/inject-report-html-plugin.ts +3 -3
- package/src/mcp/launcher-helper.ts +3 -3
- package/src/mcp/tool-generator.ts +98 -20
- package/src/mcp/types.ts +18 -1
- package/src/recorder.ts +625 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
getErrorMessage: ()=>getErrorMessage
|
|
28
|
+
});
|
|
29
|
+
function getErrorMessage(error) {
|
|
30
|
+
if (error instanceof Error) return error.message;
|
|
31
|
+
if (null == error) return String(error);
|
|
32
|
+
if ('object' != typeof error) return String(error);
|
|
33
|
+
const candidate = extractStringMessage(error);
|
|
34
|
+
if (candidate) return candidate;
|
|
35
|
+
try {
|
|
36
|
+
return JSON.stringify(error);
|
|
37
|
+
} catch {
|
|
38
|
+
return Object.prototype.toString.call(error);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function extractStringMessage(error) {
|
|
42
|
+
const anyError = error;
|
|
43
|
+
if ('string' == typeof anyError.message && anyError.message) return anyError.message;
|
|
44
|
+
if (anyError.error && 'string' == typeof anyError.error.message && anyError.error.message) return anyError.error.message;
|
|
45
|
+
if (anyError.cause && 'string' == typeof anyError.cause.message && anyError.cause.message) return anyError.cause.message;
|
|
46
|
+
}
|
|
47
|
+
exports.getErrorMessage = __webpack_exports__.getErrorMessage;
|
|
48
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
49
|
+
"getErrorMessage"
|
|
50
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
51
|
+
Object.defineProperty(exports, '__esModule', {
|
|
52
|
+
value: true
|
|
53
|
+
});
|
package/dist/lib/mcp/index.js
CHANGED
|
@@ -9,6 +9,12 @@ var __webpack_modules__ = {
|
|
|
9
9
|
"./chrome-path" (module) {
|
|
10
10
|
module.exports = require("./chrome-path.js");
|
|
11
11
|
},
|
|
12
|
+
"./error-formatter" (module) {
|
|
13
|
+
module.exports = require("./error-formatter.js");
|
|
14
|
+
},
|
|
15
|
+
"./init-arg-utils" (module) {
|
|
16
|
+
module.exports = require("./init-arg-utils.js");
|
|
17
|
+
},
|
|
12
18
|
"./inject-report-html-plugin" (module) {
|
|
13
19
|
module.exports = require("./inject-report-html-plugin.js");
|
|
14
20
|
},
|
|
@@ -73,25 +79,33 @@ var __webpack_exports__ = {};
|
|
|
73
79
|
var __rspack_reexport = {};
|
|
74
80
|
for(const __rspack_import_key in _base_tools__rspack_import_1)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_base_tools__rspack_import_1[__rspack_import_key];
|
|
75
81
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
76
|
-
var
|
|
82
|
+
var _init_arg_utils__rspack_import_2 = __webpack_require__("./init-arg-utils");
|
|
83
|
+
var __rspack_reexport = {};
|
|
84
|
+
for(const __rspack_import_key in _init_arg_utils__rspack_import_2)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_init_arg_utils__rspack_import_2[__rspack_import_key];
|
|
85
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
86
|
+
var _error_formatter__rspack_import_3 = __webpack_require__("./error-formatter");
|
|
87
|
+
var __rspack_reexport = {};
|
|
88
|
+
for(const __rspack_import_key in _error_formatter__rspack_import_3)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_error_formatter__rspack_import_3[__rspack_import_key];
|
|
89
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
90
|
+
var _tool_generator__rspack_import_4 = __webpack_require__("./tool-generator");
|
|
77
91
|
var __rspack_reexport = {};
|
|
78
|
-
for(const __rspack_import_key in
|
|
92
|
+
for(const __rspack_import_key in _tool_generator__rspack_import_4)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_tool_generator__rspack_import_4[__rspack_import_key];
|
|
79
93
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
80
|
-
var
|
|
94
|
+
var _types__rspack_import_5 = __webpack_require__("./types");
|
|
81
95
|
var __rspack_reexport = {};
|
|
82
|
-
for(const __rspack_import_key in
|
|
96
|
+
for(const __rspack_import_key in _types__rspack_import_5)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_types__rspack_import_5[__rspack_import_key];
|
|
83
97
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
84
|
-
var
|
|
98
|
+
var _inject_report_html_plugin__rspack_import_6 = __webpack_require__("./inject-report-html-plugin");
|
|
85
99
|
var __rspack_reexport = {};
|
|
86
|
-
for(const __rspack_import_key in
|
|
100
|
+
for(const __rspack_import_key in _inject_report_html_plugin__rspack_import_6)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_inject_report_html_plugin__rspack_import_6[__rspack_import_key];
|
|
87
101
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
88
|
-
var
|
|
102
|
+
var _launcher_helper__rspack_import_7 = __webpack_require__("./launcher-helper");
|
|
89
103
|
var __rspack_reexport = {};
|
|
90
|
-
for(const __rspack_import_key in
|
|
104
|
+
for(const __rspack_import_key in _launcher_helper__rspack_import_7)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_launcher_helper__rspack_import_7[__rspack_import_key];
|
|
91
105
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
92
|
-
var
|
|
106
|
+
var _chrome_path__rspack_import_8 = __webpack_require__("./chrome-path");
|
|
93
107
|
var __rspack_reexport = {};
|
|
94
|
-
for(const __rspack_import_key in
|
|
108
|
+
for(const __rspack_import_key in _chrome_path__rspack_import_8)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_chrome_path__rspack_import_8[__rspack_import_key];
|
|
95
109
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
96
110
|
})();
|
|
97
111
|
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
createNamespacedInitArgSchema: ()=>createNamespacedInitArgSchema,
|
|
28
|
+
extractNamespacedArgs: ()=>extractNamespacedArgs,
|
|
29
|
+
sanitizeNamespacedArgs: ()=>sanitizeNamespacedArgs
|
|
30
|
+
});
|
|
31
|
+
const external_key_alias_utils_js_namespaceObject = require("../key-alias-utils.js");
|
|
32
|
+
function readAliasedValue(args, key) {
|
|
33
|
+
for (const alias of (0, external_key_alias_utils_js_namespaceObject.getKeyAliases)(key))if (alias in args) return args[alias];
|
|
34
|
+
}
|
|
35
|
+
function readNamespacedArg(args, namespace, key) {
|
|
36
|
+
const namespacedArgs = readAliasedValue(args, namespace);
|
|
37
|
+
if ((0, external_key_alias_utils_js_namespaceObject.isRecord)(namespacedArgs)) {
|
|
38
|
+
const nestedValue = readAliasedValue(namespacedArgs, key);
|
|
39
|
+
if (void 0 !== nestedValue) return nestedValue;
|
|
40
|
+
}
|
|
41
|
+
const dottedValue = readAliasedValue(args, `${namespace}.${key}`);
|
|
42
|
+
if (void 0 !== dottedValue) return dottedValue;
|
|
43
|
+
const directValue = readAliasedValue(args, key);
|
|
44
|
+
if (void 0 !== directValue) return directValue;
|
|
45
|
+
}
|
|
46
|
+
function extractNamespacedArgs(args, namespace, keys) {
|
|
47
|
+
const extracted = {};
|
|
48
|
+
for (const key of keys){
|
|
49
|
+
const value = readNamespacedArg(args, namespace, key);
|
|
50
|
+
if (void 0 !== value) extracted[key] = value;
|
|
51
|
+
}
|
|
52
|
+
return Object.keys(extracted).length > 0 ? extracted : void 0;
|
|
53
|
+
}
|
|
54
|
+
function sanitizeNamespacedArgs(args, namespace, keys) {
|
|
55
|
+
const excludedKeys = new Set((0, external_key_alias_utils_js_namespaceObject.getKeyAliases)(namespace));
|
|
56
|
+
for (const key of keys){
|
|
57
|
+
for (const alias of (0, external_key_alias_utils_js_namespaceObject.getKeyAliases)(key))excludedKeys.add(alias);
|
|
58
|
+
for (const alias of (0, external_key_alias_utils_js_namespaceObject.getKeyAliases)(`${namespace}.${key}`))excludedKeys.add(alias);
|
|
59
|
+
}
|
|
60
|
+
return Object.fromEntries(Object.entries(args).filter(([key])=>!excludedKeys.has(key)));
|
|
61
|
+
}
|
|
62
|
+
function createNamespacedInitArgSchema(namespace, shape) {
|
|
63
|
+
return Object.fromEntries(Object.entries(shape).map(([key, value])=>[
|
|
64
|
+
`${namespace}.${key}`,
|
|
65
|
+
value
|
|
66
|
+
]));
|
|
67
|
+
}
|
|
68
|
+
exports.createNamespacedInitArgSchema = __webpack_exports__.createNamespacedInitArgSchema;
|
|
69
|
+
exports.extractNamespacedArgs = __webpack_exports__.extractNamespacedArgs;
|
|
70
|
+
exports.sanitizeNamespacedArgs = __webpack_exports__.sanitizeNamespacedArgs;
|
|
71
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
72
|
+
"createNamespacedInitArgSchema",
|
|
73
|
+
"extractNamespacedArgs",
|
|
74
|
+
"sanitizeNamespacedArgs"
|
|
75
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
76
|
+
Object.defineProperty(exports, '__esModule', {
|
|
77
|
+
value: true
|
|
78
|
+
});
|
|
@@ -48,7 +48,7 @@ function injectReportHtmlFromCore(packageDir) {
|
|
|
48
48
|
setup (api) {
|
|
49
49
|
api.onAfterBuild(()=>{
|
|
50
50
|
const coreUtilsPath = external_node_path_default().resolve(packageDir, '..', 'core', 'dist', 'lib', 'utils.js');
|
|
51
|
-
if (!external_node_fs_default().existsSync(coreUtilsPath)) return void console.warn('[inject-report-html] @
|
|
51
|
+
if (!external_node_fs_default().existsSync(coreUtilsPath)) return void console.warn('[inject-report-html] @aiscene/core dist not found, skipping');
|
|
52
52
|
const coreContent = external_node_fs_default().readFileSync(coreUtilsPath, 'utf-8');
|
|
53
53
|
if (!coreContent.includes(REPLACED_MARK)) return void console.warn('[inject-report-html] HTML not found in core dist. Ensure report builds first.');
|
|
54
54
|
const markerIndex = coreContent.indexOf(REPLACED_MARK);
|
|
@@ -27,12 +27,10 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27
27
|
generateToolsFromActionSpace: ()=>generateToolsFromActionSpace,
|
|
28
28
|
generateCommonTools: ()=>generateCommonTools
|
|
29
29
|
});
|
|
30
|
+
const img_namespaceObject = require("@aiscene/shared/img");
|
|
30
31
|
const external_zod_namespaceObject = require("zod");
|
|
31
|
-
const index_js_namespaceObject = require("../img/index.js");
|
|
32
32
|
const external_zod_schema_utils_js_namespaceObject = require("../zod-schema-utils.js");
|
|
33
|
-
|
|
34
|
-
return error instanceof Error ? error.message : String(error);
|
|
35
|
-
}
|
|
33
|
+
const external_error_formatter_js_namespaceObject = require("./error-formatter.js");
|
|
36
34
|
function describeActionForMCP(action) {
|
|
37
35
|
const actionDesc = action.description || `Execute ${action.name} action`;
|
|
38
36
|
if (!action.paramSchema) return `${action.name} action, ${actionDesc}`;
|
|
@@ -99,10 +97,13 @@ function transformSchemaField(key, value) {
|
|
|
99
97
|
value
|
|
100
98
|
];
|
|
101
99
|
}
|
|
102
|
-
function extractActionSchema(paramSchema) {
|
|
100
|
+
function extractActionSchema(paramSchema, actionName) {
|
|
103
101
|
if (!paramSchema) return {};
|
|
104
102
|
const shape = getZodObjectShape(paramSchema);
|
|
105
|
-
if (!shape)
|
|
103
|
+
if (!shape) {
|
|
104
|
+
const typeName = paramSchema?._def?.typeName ?? 'unknown';
|
|
105
|
+
throw new Error(`Action "${actionName}" declared a non-object paramSchema (${typeName}). CLI and MCP tool schemas must be a ZodObject (e.g. z.object({ uri: z.string() })) or undefined. Wrap primitive fields in an object schema.`);
|
|
106
|
+
}
|
|
106
107
|
return Object.fromEntries(Object.entries(shape).map(([key, value])=>transformSchemaField(key, value)));
|
|
107
108
|
}
|
|
108
109
|
function getPromptText(prompt) {
|
|
@@ -173,7 +174,7 @@ function serializeArgsToDescription(args) {
|
|
|
173
174
|
return `${key}: "${value}"`;
|
|
174
175
|
}).join(', ');
|
|
175
176
|
} catch (error) {
|
|
176
|
-
const errorMessage = getErrorMessage(error);
|
|
177
|
+
const errorMessage = (0, external_error_formatter_js_namespaceObject.getErrorMessage)(error);
|
|
177
178
|
console.error('Error serializing args:', errorMessage);
|
|
178
179
|
return `[args serialization failed: ${errorMessage}]`;
|
|
179
180
|
}
|
|
@@ -231,7 +232,7 @@ async function captureScreenshotResult(agent, actionName, actionResult) {
|
|
|
231
232
|
if (!screenshot) return {
|
|
232
233
|
content
|
|
233
234
|
};
|
|
234
|
-
const { mimeType, body } = (0,
|
|
235
|
+
const { mimeType, body } = (0, img_namespaceObject.parseBase64)(screenshot);
|
|
235
236
|
content.push({
|
|
236
237
|
type: 'image',
|
|
237
238
|
data: body,
|
|
@@ -241,7 +242,7 @@ async function captureScreenshotResult(agent, actionName, actionResult) {
|
|
|
241
242
|
content
|
|
242
243
|
};
|
|
243
244
|
} catch (error) {
|
|
244
|
-
const errorMessage = getErrorMessage(error);
|
|
245
|
+
const errorMessage = (0, external_error_formatter_js_namespaceObject.getErrorMessage)(error);
|
|
245
246
|
console.error('Error capturing screenshot:', errorMessage);
|
|
246
247
|
content[0] = {
|
|
247
248
|
type: 'text',
|
|
@@ -283,7 +284,7 @@ async function captureFailureResult(agent, actionName, errorMessage) {
|
|
|
283
284
|
}
|
|
284
285
|
]
|
|
285
286
|
};
|
|
286
|
-
const { mimeType, body } = (0,
|
|
287
|
+
const { mimeType, body } = (0, img_namespaceObject.parseBase64)(screenshot);
|
|
287
288
|
return {
|
|
288
289
|
content: [
|
|
289
290
|
{
|
|
@@ -308,28 +309,41 @@ async function captureFailureResult(agent, actionName, errorMessage) {
|
|
|
308
309
|
};
|
|
309
310
|
}
|
|
310
311
|
}
|
|
311
|
-
function
|
|
312
|
+
function mergeToolCliMetadata(base, extra) {
|
|
313
|
+
const options = {
|
|
314
|
+
...base?.options ?? {},
|
|
315
|
+
...extra?.options ?? {}
|
|
316
|
+
};
|
|
317
|
+
return Object.keys(options).length > 0 ? {
|
|
318
|
+
options
|
|
319
|
+
} : void 0;
|
|
320
|
+
}
|
|
321
|
+
function generateToolsFromActionSpace(actionSpace, getAgent, sanitizeArgs = (args)=>args, initArgSchema = {}, initArgCliMetadata) {
|
|
312
322
|
return actionSpace.map((action)=>{
|
|
313
|
-
const schema =
|
|
323
|
+
const schema = {
|
|
324
|
+
...extractActionSchema(action.paramSchema, action.name),
|
|
325
|
+
...initArgSchema
|
|
326
|
+
};
|
|
314
327
|
return {
|
|
315
328
|
name: action.name,
|
|
316
329
|
description: describeActionForMCP(action),
|
|
317
330
|
schema,
|
|
331
|
+
cli: initArgCliMetadata,
|
|
318
332
|
handler: async (args)=>{
|
|
319
333
|
try {
|
|
320
|
-
const agent = await getAgent();
|
|
321
|
-
const normalizedArgs = normalizeActionArgs(args, action.paramSchema);
|
|
334
|
+
const agent = await getAgent(args);
|
|
335
|
+
const normalizedArgs = normalizeActionArgs(sanitizeArgs(args), action.paramSchema);
|
|
322
336
|
let actionResult;
|
|
323
337
|
try {
|
|
324
338
|
actionResult = await executeAction(agent, action.name, normalizedArgs);
|
|
325
339
|
} catch (error) {
|
|
326
|
-
const errorMessage = getErrorMessage(error);
|
|
340
|
+
const errorMessage = (0, external_error_formatter_js_namespaceObject.getErrorMessage)(error);
|
|
327
341
|
console.error(`Error executing action "${action.name}":`, errorMessage);
|
|
328
342
|
return await captureFailureResult(agent, action.name, errorMessage);
|
|
329
343
|
}
|
|
330
344
|
return await captureScreenshotResult(agent, action.name, actionResult);
|
|
331
345
|
} catch (error) {
|
|
332
|
-
const errorMessage = getErrorMessage(error);
|
|
346
|
+
const errorMessage = (0, external_error_formatter_js_namespaceObject.getErrorMessage)(error);
|
|
333
347
|
console.error(`Error in handler for "${action.name}":`, errorMessage);
|
|
334
348
|
return createErrorResult(`Failed to get agent or execute action "${action.name}": ${errorMessage}`);
|
|
335
349
|
}
|
|
@@ -337,18 +351,21 @@ function generateToolsFromActionSpace(actionSpace, getAgent) {
|
|
|
337
351
|
};
|
|
338
352
|
});
|
|
339
353
|
}
|
|
340
|
-
function generateCommonTools(getAgent) {
|
|
354
|
+
function generateCommonTools(getAgent, initArgSchema = {}, initArgCliMetadata) {
|
|
341
355
|
return [
|
|
342
356
|
{
|
|
343
357
|
name: 'take_screenshot',
|
|
344
358
|
description: 'Capture screenshot of current page/screen',
|
|
345
|
-
schema: {
|
|
346
|
-
|
|
359
|
+
schema: {
|
|
360
|
+
...initArgSchema
|
|
361
|
+
},
|
|
362
|
+
cli: initArgCliMetadata,
|
|
363
|
+
handler: async (args = {})=>{
|
|
347
364
|
try {
|
|
348
|
-
const agent = await getAgent();
|
|
365
|
+
const agent = await getAgent(args);
|
|
349
366
|
const screenshot = await agent.page?.screenshotBase64();
|
|
350
367
|
if (!screenshot) return createErrorResult('Screenshot not available');
|
|
351
|
-
const { mimeType, body } = (0,
|
|
368
|
+
const { mimeType, body } = (0, img_namespaceObject.parseBase64)(screenshot);
|
|
352
369
|
return {
|
|
353
370
|
content: [
|
|
354
371
|
{
|
|
@@ -359,7 +376,7 @@ function generateCommonTools(getAgent) {
|
|
|
359
376
|
]
|
|
360
377
|
};
|
|
361
378
|
} catch (error) {
|
|
362
|
-
const errorMessage = getErrorMessage(error);
|
|
379
|
+
const errorMessage = (0, external_error_formatter_js_namespaceObject.getErrorMessage)(error);
|
|
363
380
|
console.error('Error taking screenshot:', errorMessage);
|
|
364
381
|
return createErrorResult(`Failed to capture screenshot: ${errorMessage}`);
|
|
365
382
|
}
|
|
@@ -369,12 +386,14 @@ function generateCommonTools(getAgent) {
|
|
|
369
386
|
name: 'act',
|
|
370
387
|
description: 'Execute a natural language action. The AI will plan and perform multi-step operations in a single invocation, useful for transient UI interactions (e.g., Spotlight, dropdown menus) that disappear between separate commands.',
|
|
371
388
|
schema: {
|
|
372
|
-
prompt: external_zod_namespaceObject.z.string().describe('Natural language description of the action to perform, e.g. "press Command+Space, type Safari, press Enter"')
|
|
389
|
+
prompt: external_zod_namespaceObject.z.string().describe('Natural language description of the action to perform, e.g. "press Command+Space, type Safari, press Enter"'),
|
|
390
|
+
...initArgSchema
|
|
373
391
|
},
|
|
374
|
-
|
|
392
|
+
cli: mergeToolCliMetadata(void 0, initArgCliMetadata),
|
|
393
|
+
handler: async (args = {})=>{
|
|
375
394
|
const prompt = args.prompt;
|
|
376
395
|
try {
|
|
377
|
-
const agent = await getAgent();
|
|
396
|
+
const agent = await getAgent(args);
|
|
378
397
|
if (!agent.aiAction) return createErrorResult('act is not supported by this agent');
|
|
379
398
|
const result = await agent.aiAction(prompt, {
|
|
380
399
|
deepThink: false
|
|
@@ -389,11 +408,40 @@ function generateCommonTools(getAgent) {
|
|
|
389
408
|
}
|
|
390
409
|
return screenshotResult;
|
|
391
410
|
} catch (error) {
|
|
392
|
-
const errorMessage = getErrorMessage(error);
|
|
411
|
+
const errorMessage = (0, external_error_formatter_js_namespaceObject.getErrorMessage)(error);
|
|
393
412
|
console.error('Error executing act:', errorMessage);
|
|
394
413
|
return createErrorResult(`Failed to execute act: ${errorMessage}`);
|
|
395
414
|
}
|
|
396
415
|
}
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
name: 'assert',
|
|
419
|
+
description: 'Assert a natural language statement against the current page/screen.',
|
|
420
|
+
schema: {
|
|
421
|
+
prompt: external_zod_namespaceObject.z.string().describe('Natural language assertion to verify, e.g. "there is a login button visible"'),
|
|
422
|
+
...initArgSchema
|
|
423
|
+
},
|
|
424
|
+
cli: mergeToolCliMetadata(void 0, initArgCliMetadata),
|
|
425
|
+
handler: async (args = {})=>{
|
|
426
|
+
const prompt = args.prompt;
|
|
427
|
+
try {
|
|
428
|
+
const agent = await getAgent(args);
|
|
429
|
+
if (!agent.aiAssert) return createErrorResult('assert is not supported by this agent');
|
|
430
|
+
await agent.aiAssert(prompt);
|
|
431
|
+
return {
|
|
432
|
+
content: [
|
|
433
|
+
{
|
|
434
|
+
type: 'text',
|
|
435
|
+
text: 'Assertion passed.'
|
|
436
|
+
}
|
|
437
|
+
]
|
|
438
|
+
};
|
|
439
|
+
} catch (error) {
|
|
440
|
+
const errorMessage = (0, external_error_formatter_js_namespaceObject.getErrorMessage)(error);
|
|
441
|
+
console.error('Error executing assert:', errorMessage);
|
|
442
|
+
return createErrorResult(`Failed to execute assert: ${errorMessage}`);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
397
445
|
}
|
|
398
446
|
];
|
|
399
447
|
}
|