@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,465 @@
|
|
|
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
|
+
getCliVerboseContext: ()=>getCliVerboseContext,
|
|
28
|
+
attachCliVerboseDumpListener: ()=>attachCliVerboseDumpListener,
|
|
29
|
+
compactCliVerboseValue: ()=>compactCliVerboseValue,
|
|
30
|
+
cliVerboseFlag: ()=>cliVerboseFlag,
|
|
31
|
+
emitCliVerboseEvent: ()=>emitCliVerboseEvent,
|
|
32
|
+
cliVerboseErrorMessage: ()=>errorMessageOf,
|
|
33
|
+
compactCliVerboseArgs: ()=>compactCliVerboseArgs,
|
|
34
|
+
stripVerboseFlag: ()=>stripVerboseFlag,
|
|
35
|
+
isCliVerboseEnabled: ()=>isCliVerboseEnabled,
|
|
36
|
+
withCliVerboseContext: ()=>withCliVerboseContext
|
|
37
|
+
});
|
|
38
|
+
const external_verbose_ai_act_js_namespaceObject = require("./verbose-ai-act.js");
|
|
39
|
+
const external_verbose_screenshot_js_namespaceObject = require("./verbose-screenshot.js");
|
|
40
|
+
const cliVerboseFlag = 'verbose';
|
|
41
|
+
const progressRenderers = {
|
|
42
|
+
[external_verbose_ai_act_js_namespaceObject.cliAiActProgressScope]: external_verbose_ai_act_js_namespaceObject.aiActCliProgressRenderer
|
|
43
|
+
};
|
|
44
|
+
function progressRendererForEvent(event) {
|
|
45
|
+
if ('object' != typeof event || null === event) return;
|
|
46
|
+
const scope = event.scope;
|
|
47
|
+
if ('string' != typeof scope) return;
|
|
48
|
+
const renderer = progressRenderers[scope];
|
|
49
|
+
return renderer ? {
|
|
50
|
+
scope,
|
|
51
|
+
renderer
|
|
52
|
+
} : void 0;
|
|
53
|
+
}
|
|
54
|
+
const progressEventName = 'midscene_progress';
|
|
55
|
+
const cliVerboseContextKey = '__midscene_cli_verbose_context__';
|
|
56
|
+
const getGlobalContext = ()=>{
|
|
57
|
+
const globalWithContext = globalThis;
|
|
58
|
+
if (!globalWithContext[cliVerboseContextKey]) globalWithContext[cliVerboseContextKey] = {
|
|
59
|
+
current: {
|
|
60
|
+
enabled: false
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return globalWithContext[cliVerboseContextKey];
|
|
64
|
+
};
|
|
65
|
+
function parseVerboseFormat(rawFormat) {
|
|
66
|
+
if ('text' === rawFormat || 'jsonl' === rawFormat) return rawFormat;
|
|
67
|
+
throw new Error(`Unsupported --${cliVerboseFlag} format "${rawFormat}". Use "--${cliVerboseFlag}" or "--${cliVerboseFlag}=jsonl".`);
|
|
68
|
+
}
|
|
69
|
+
function stripVerboseFlag(argv) {
|
|
70
|
+
const rawArgs = [];
|
|
71
|
+
let verbose = false;
|
|
72
|
+
let format = 'text';
|
|
73
|
+
for (const arg of argv){
|
|
74
|
+
if (arg === `--${cliVerboseFlag}`) {
|
|
75
|
+
verbose = true;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (arg.startsWith(`--${cliVerboseFlag}=`)) {
|
|
79
|
+
verbose = true;
|
|
80
|
+
format = parseVerboseFormat(arg.slice(`--${cliVerboseFlag}=`.length));
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
rawArgs.push(arg);
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
rawArgs,
|
|
87
|
+
verbose,
|
|
88
|
+
format
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
async function withCliVerboseContext(context, fn) {
|
|
92
|
+
const globalContext = getGlobalContext();
|
|
93
|
+
const previous = globalContext.current;
|
|
94
|
+
globalContext.current = {
|
|
95
|
+
...context,
|
|
96
|
+
renderedLineKeys: context.renderedLineKeys ?? new Set()
|
|
97
|
+
};
|
|
98
|
+
try {
|
|
99
|
+
return await fn();
|
|
100
|
+
} finally{
|
|
101
|
+
globalContext.current = previous;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function getCliVerboseContext() {
|
|
105
|
+
return getGlobalContext().current;
|
|
106
|
+
}
|
|
107
|
+
function isCliVerboseEnabled() {
|
|
108
|
+
return getCliVerboseContext().enabled;
|
|
109
|
+
}
|
|
110
|
+
function emitCliVerboseEvent(event) {
|
|
111
|
+
const context = getCliVerboseContext();
|
|
112
|
+
if (!context.enabled) return;
|
|
113
|
+
const payload = {
|
|
114
|
+
type: progressEventName,
|
|
115
|
+
timestamp: new Date().toISOString(),
|
|
116
|
+
scriptName: context.scriptName,
|
|
117
|
+
command: context.commandName,
|
|
118
|
+
...event
|
|
119
|
+
};
|
|
120
|
+
if ('jsonl' === context.format) return void console.log(JSON.stringify(payload));
|
|
121
|
+
const text = renderCliVerboseEventText(payload, context);
|
|
122
|
+
if (text) console.log(text);
|
|
123
|
+
}
|
|
124
|
+
function errorMessageOf(error) {
|
|
125
|
+
return error instanceof Error ? error.message : String(error);
|
|
126
|
+
}
|
|
127
|
+
function isRecord(value) {
|
|
128
|
+
return 'object' == typeof value && null !== value && !Array.isArray(value);
|
|
129
|
+
}
|
|
130
|
+
function compactText(value) {
|
|
131
|
+
if (null == value || '' === value) return '';
|
|
132
|
+
if ('string' == typeof value) return value.length > 180 ? `${value.slice(0, 177)}...` : value;
|
|
133
|
+
if ('number' == typeof value || 'boolean' == typeof value) return String(value);
|
|
134
|
+
try {
|
|
135
|
+
const json = JSON.stringify(value);
|
|
136
|
+
return json.length > 180 ? `${json.slice(0, 177)}...` : json;
|
|
137
|
+
} catch {
|
|
138
|
+
return String(value);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function compactPrimitiveCliVerboseValue(value) {
|
|
142
|
+
if (null == value) return {
|
|
143
|
+
handled: true,
|
|
144
|
+
value
|
|
145
|
+
};
|
|
146
|
+
if ('string' == typeof value) return {
|
|
147
|
+
handled: true,
|
|
148
|
+
value: value.length > 180 ? `${value.slice(0, 177)}...` : value
|
|
149
|
+
};
|
|
150
|
+
if ('number' == typeof value || 'boolean' == typeof value) return {
|
|
151
|
+
handled: true,
|
|
152
|
+
value
|
|
153
|
+
};
|
|
154
|
+
if ('object' != typeof value) return {
|
|
155
|
+
handled: true,
|
|
156
|
+
value: String(value)
|
|
157
|
+
};
|
|
158
|
+
return {
|
|
159
|
+
handled: false
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function compactStructuredCliVerboseValue(value) {
|
|
163
|
+
const primitive = compactPrimitiveCliVerboseValue(value);
|
|
164
|
+
if (primitive.handled) return primitive.value;
|
|
165
|
+
if (Array.isArray(value)) return value.slice(0, 5).map(compactStructuredCliVerboseValue);
|
|
166
|
+
if (!isRecord(value)) return String(value);
|
|
167
|
+
const entries = Object.entries(value).slice(0, 6);
|
|
168
|
+
return Object.fromEntries(entries.map(([key, entryValue])=>[
|
|
169
|
+
key,
|
|
170
|
+
compactStructuredCliVerboseValue(entryValue)
|
|
171
|
+
]));
|
|
172
|
+
}
|
|
173
|
+
function compactCliVerboseValue(value) {
|
|
174
|
+
const primitive = compactPrimitiveCliVerboseValue(value);
|
|
175
|
+
if (primitive.handled) return primitive.value;
|
|
176
|
+
if (Array.isArray(value)) return value.slice(0, 5).map(compactCliVerboseValue);
|
|
177
|
+
if (isRecord(value) && 'string' == typeof value.prompt) return compactCliVerboseValue(value.prompt);
|
|
178
|
+
if (!isRecord(value)) return String(value);
|
|
179
|
+
const entries = Object.entries(value).slice(0, 6);
|
|
180
|
+
return Object.fromEntries(entries.map(([key, entryValue])=>[
|
|
181
|
+
key,
|
|
182
|
+
compactCliVerboseValue(entryValue)
|
|
183
|
+
]));
|
|
184
|
+
}
|
|
185
|
+
function compactCliVerboseArgs(args) {
|
|
186
|
+
return Object.fromEntries(Object.entries(args).slice(0, 8).map(([key, value])=>[
|
|
187
|
+
key,
|
|
188
|
+
compactStructuredCliVerboseValue(value)
|
|
189
|
+
]));
|
|
190
|
+
}
|
|
191
|
+
function summarizeParam(param) {
|
|
192
|
+
if (!param || 'object' != typeof param) return compactCliVerboseValue(param);
|
|
193
|
+
const record = param;
|
|
194
|
+
if ('string' == typeof record.prompt) return compactCliVerboseValue(record.prompt);
|
|
195
|
+
if (record.locate && 'object' == typeof record.locate && null !== record.locate) {
|
|
196
|
+
const locate = record.locate;
|
|
197
|
+
return {
|
|
198
|
+
locate: compactCliVerboseValue(locate.prompt),
|
|
199
|
+
...Object.fromEntries(Object.entries(record).filter(([key])=>'locate' !== key).slice(0, 4).map(([key, value])=>[
|
|
200
|
+
key,
|
|
201
|
+
compactCliVerboseValue(value)
|
|
202
|
+
]))
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
return compactCliVerboseValue(record);
|
|
206
|
+
}
|
|
207
|
+
function summarizeUserInstruction(value) {
|
|
208
|
+
if ('string' == typeof value) return compactText(value);
|
|
209
|
+
if (isRecord(value) && 'string' == typeof value.prompt) return compactText(value.prompt);
|
|
210
|
+
return compactText(value);
|
|
211
|
+
}
|
|
212
|
+
function summarizeTaskParamText(task) {
|
|
213
|
+
if (!isRecord(task.param)) return compactText(summarizeParam(task.param));
|
|
214
|
+
if ('Planning' === task.type && 'Locate' !== task.subType) {
|
|
215
|
+
if (task.param.userInstructionDisplay) return summarizeUserInstruction(task.param.userInstructionDisplay);
|
|
216
|
+
if (task.param.userInstruction) return summarizeUserInstruction(task.param.userInstruction);
|
|
217
|
+
}
|
|
218
|
+
if (task.param.dataDemand) return compactText(summarizeParam(task.param.dataDemand));
|
|
219
|
+
if (task.param.assertion) return compactText(summarizeParam(task.param.assertion));
|
|
220
|
+
return compactText(summarizeParam(task.param));
|
|
221
|
+
}
|
|
222
|
+
function summarizeSubGoals(value) {
|
|
223
|
+
if (!Array.isArray(value) || 0 === value.length) return '';
|
|
224
|
+
const goals = value.slice(0, 6).map((goal)=>{
|
|
225
|
+
if (!isRecord(goal)) return '';
|
|
226
|
+
const index = 'number' == typeof goal.index ? `${goal.index}. ` : '';
|
|
227
|
+
const status = 'string' == typeof goal.status ? `[${goal.status}] ` : '';
|
|
228
|
+
const description = 'string' == typeof goal.description ? goal.description : '';
|
|
229
|
+
return `${index}${status}${description}`.trim();
|
|
230
|
+
}).filter(Boolean);
|
|
231
|
+
return goals.length > 0 ? `sub-goals: ${goals.join('; ')}` : '';
|
|
232
|
+
}
|
|
233
|
+
function summarizeActions(value) {
|
|
234
|
+
if (!Array.isArray(value) || 0 === value.length) return '';
|
|
235
|
+
const actions = value.slice(0, 5).map((action)=>{
|
|
236
|
+
if (!isRecord(action)) return '';
|
|
237
|
+
const type = 'string' == typeof action.type ? action.type : 'Action';
|
|
238
|
+
const param = compactText(summarizeParam(action.param));
|
|
239
|
+
return param ? `${type}: ${param}` : type;
|
|
240
|
+
}).filter(Boolean);
|
|
241
|
+
return actions.length > 0 ? `actions: ${actions.join('; ')}` : '';
|
|
242
|
+
}
|
|
243
|
+
function summarizeTaskOutputText(task) {
|
|
244
|
+
if (!isRecord(task.output)) return compactText(task.output);
|
|
245
|
+
return summarizeSubGoals(task.output.updateSubGoals) || compactText(task.output.log) || compactText(task.output.output) || summarizeActions(task.output.actions);
|
|
246
|
+
}
|
|
247
|
+
function summarizeTaskText(task) {
|
|
248
|
+
const parts = [
|
|
249
|
+
task.type,
|
|
250
|
+
task.subType
|
|
251
|
+
].filter((part)=>'string' == typeof part && part.length > 0);
|
|
252
|
+
const label = parts.length > 0 ? parts.join('/') : 'Task';
|
|
253
|
+
const status = 'string' == typeof task.status && task.status.length > 0 ? task.status : 'unknown';
|
|
254
|
+
const param = summarizeTaskParamText(task);
|
|
255
|
+
const output = summarizeTaskOutputText(task);
|
|
256
|
+
const thought = compactText(task.thought);
|
|
257
|
+
const detail = output || thought || param;
|
|
258
|
+
return detail ? `${label} ${status}: ${detail}` : `${label} ${status}`;
|
|
259
|
+
}
|
|
260
|
+
function isCliVerboseExecutionDumpLike(value) {
|
|
261
|
+
return isRecord(value) && Array.isArray(value.tasks);
|
|
262
|
+
}
|
|
263
|
+
function summarizeDumpUpdate(executionDump, screenshotOptions = {}) {
|
|
264
|
+
if (!isCliVerboseExecutionDumpLike(executionDump)) return;
|
|
265
|
+
const tasks = executionDump.tasks;
|
|
266
|
+
const latestTask = tasks[tasks.length - 1];
|
|
267
|
+
const steps = tasks.map((task, index)=>({
|
|
268
|
+
id: task.taskId,
|
|
269
|
+
index: index + 1,
|
|
270
|
+
total: tasks.length,
|
|
271
|
+
type: task.type,
|
|
272
|
+
subType: task.subType,
|
|
273
|
+
status: task.status,
|
|
274
|
+
param: summarizeParam(task.param),
|
|
275
|
+
message: summarizeTaskText(task),
|
|
276
|
+
error: task.errorMessage,
|
|
277
|
+
durationMs: task.timing?.cost,
|
|
278
|
+
screenshots: (0, external_verbose_screenshot_js_namespaceObject.collectScreenshotRefs)(task, screenshotOptions).slice(-3)
|
|
279
|
+
}));
|
|
280
|
+
return {
|
|
281
|
+
execution: {
|
|
282
|
+
id: executionDump.id,
|
|
283
|
+
name: executionDump.name,
|
|
284
|
+
description: compactCliVerboseValue(executionDump.description),
|
|
285
|
+
taskCount: tasks.length
|
|
286
|
+
},
|
|
287
|
+
steps,
|
|
288
|
+
task: latestTask ? {
|
|
289
|
+
id: latestTask.taskId,
|
|
290
|
+
index: tasks.length,
|
|
291
|
+
total: tasks.length,
|
|
292
|
+
type: latestTask.type,
|
|
293
|
+
subType: latestTask.subType,
|
|
294
|
+
status: latestTask.status,
|
|
295
|
+
param: summarizeParam(latestTask.param),
|
|
296
|
+
message: summarizeTaskText(latestTask),
|
|
297
|
+
error: latestTask.errorMessage,
|
|
298
|
+
durationMs: latestTask.timing?.cost
|
|
299
|
+
} : void 0,
|
|
300
|
+
screenshots: (0, external_verbose_screenshot_js_namespaceObject.collectScreenshotRefs)(tasks, screenshotOptions).slice(-5)
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function stringifyArgs(args) {
|
|
304
|
+
if (!isRecord(args) || 0 === Object.keys(args).length) return '';
|
|
305
|
+
return Object.entries(args).map(([key, value])=>`${key}=${compactText(value)}`).join(', ');
|
|
306
|
+
}
|
|
307
|
+
function isActVerboseEvent(command, tool) {
|
|
308
|
+
return 'act' === command || 'act' === tool;
|
|
309
|
+
}
|
|
310
|
+
function renderLinesOnce(context, lines) {
|
|
311
|
+
if (0 === lines.length) return;
|
|
312
|
+
if (!context.renderedLineKeys) context.renderedLineKeys = new Set();
|
|
313
|
+
const renderedLineKeys = context.renderedLineKeys;
|
|
314
|
+
const pendingLines = lines.filter((line)=>{
|
|
315
|
+
if (renderedLineKeys.has(line.key)) return false;
|
|
316
|
+
renderedLineKeys.add(line.key);
|
|
317
|
+
return true;
|
|
318
|
+
});
|
|
319
|
+
return pendingLines.length > 0 ? pendingLines.map((line)=>line.text).join('\n') : void 0;
|
|
320
|
+
}
|
|
321
|
+
function renderCliVerboseEventText(event, context) {
|
|
322
|
+
const command = 'string' == typeof event.command ? event.command : 'command';
|
|
323
|
+
const tool = 'string' == typeof event.tool ? event.tool : void 0;
|
|
324
|
+
switch(event.event){
|
|
325
|
+
case 'agent_progress':
|
|
326
|
+
{
|
|
327
|
+
const scope = 'string' == typeof event.scope ? event.scope : void 0;
|
|
328
|
+
const renderer = scope ? progressRenderers[scope] : void 0;
|
|
329
|
+
const progressEvent = isRecord(event.progress) ? event.progress : void 0;
|
|
330
|
+
if (!renderer || !progressEvent) return;
|
|
331
|
+
return renderLinesOnce(context, renderer.buildLines(progressEvent));
|
|
332
|
+
}
|
|
333
|
+
case 'command_start':
|
|
334
|
+
{
|
|
335
|
+
if (isActVerboseEvent(command, tool)) return;
|
|
336
|
+
const args = stringifyArgs(event.args);
|
|
337
|
+
return args ? `[Midscene] ${command} started (${args})` : `[Midscene] ${command} started`;
|
|
338
|
+
}
|
|
339
|
+
case 'agent_ready':
|
|
340
|
+
if (isActVerboseEvent(command, tool)) return;
|
|
341
|
+
return `[Midscene] ${tool ?? command} ready`;
|
|
342
|
+
case 'recording_ready':
|
|
343
|
+
return '[Midscene] Recording. Press Ctrl+C to stop and save.';
|
|
344
|
+
case 'recording_stopping':
|
|
345
|
+
if ('watchdog' === event.reason) return '[Midscene] Recording watchdog reached; finalizing and saving.';
|
|
346
|
+
if ('sigterm' === event.reason) return '[Midscene] SIGTERM received; finalizing and saving.';
|
|
347
|
+
return 'sighup' === event.reason ? '[Midscene] SIGHUP received; finalizing and saving.' : '[Midscene] Ctrl+C received; finalizing and saving. Press Ctrl+C again to force exit.';
|
|
348
|
+
case 'dump_update':
|
|
349
|
+
{
|
|
350
|
+
if (isActVerboseEvent(command, tool)) return;
|
|
351
|
+
const task = isRecord(event.task) ? event.task : void 0;
|
|
352
|
+
const steps = Array.isArray(event.steps) ? event.steps.filter(isRecord) : [];
|
|
353
|
+
const execution = isRecord(event.execution) ? event.execution : void 0;
|
|
354
|
+
const executionName = 'string' == typeof execution?.name ? execution.name : 'execution';
|
|
355
|
+
const lines = steps.length > 0 ? [
|
|
356
|
+
`[Midscene] Progress: ${executionName} (${steps.length} steps)`,
|
|
357
|
+
...steps.map((step)=>{
|
|
358
|
+
const index = 'number' == typeof step.index && 'number' == typeof step.total ? `Step ${step.index}/${step.total}` : 'Step';
|
|
359
|
+
const message = 'string' == typeof step.message ? step.message : 'string' == typeof step.status ? step.status : 'updated';
|
|
360
|
+
return `[Midscene] ${index}: ${message}`;
|
|
361
|
+
})
|
|
362
|
+
] : [
|
|
363
|
+
`[Midscene] Step: ${'string' == typeof task?.message ? task.message : 'string' == typeof task?.status ? task.status : 'updated'}`
|
|
364
|
+
];
|
|
365
|
+
const screenshots = (0, external_verbose_screenshot_js_namespaceObject.renderScreenshotList)(event.screenshots);
|
|
366
|
+
if (screenshots) lines.push(`[Midscene] Screenshot: ${screenshots}`);
|
|
367
|
+
if ('string' == typeof event.report && event.report.length > 0) lines.push(`[Midscene] Report: ${event.report}`);
|
|
368
|
+
return lines.join('\n');
|
|
369
|
+
}
|
|
370
|
+
case 'artifact':
|
|
371
|
+
{
|
|
372
|
+
if (isActVerboseEvent(command, tool)) return;
|
|
373
|
+
const kind = 'string' == typeof event.kind ? event.kind : 'artifact';
|
|
374
|
+
const path = 'string' == typeof event.path ? event.path : void 0;
|
|
375
|
+
return path ? `[Midscene] ${kind} saved: ${path}` : `[Midscene] ${kind} ready`;
|
|
376
|
+
}
|
|
377
|
+
case 'command_done':
|
|
378
|
+
{
|
|
379
|
+
if (isActVerboseEvent(command, tool)) {
|
|
380
|
+
if ('error' === event.status) {
|
|
381
|
+
const error = 'string' == typeof event.error && event.error.length > 0 ? `: ${event.error}` : '';
|
|
382
|
+
return renderLinesOnce(context, [
|
|
383
|
+
{
|
|
384
|
+
key: `aiAct:command_failed:${event.error ?? 'unknown'}`,
|
|
385
|
+
text: `[Midscene][aiAct] Failed${error}`
|
|
386
|
+
}
|
|
387
|
+
]);
|
|
388
|
+
}
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
const status = 'error' === event.status ? 'failed' : 'finished';
|
|
392
|
+
const duration = 'number' == typeof event.durationMs ? ` in ${event.durationMs}ms` : '';
|
|
393
|
+
const error = 'error' === event.status && 'string' == typeof event.error ? `: ${event.error}` : '';
|
|
394
|
+
return `[Midscene] ${command} ${status}${duration}${error}`;
|
|
395
|
+
}
|
|
396
|
+
default:
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
function attachCliVerboseDumpListener(agent, options) {
|
|
401
|
+
if (!isCliVerboseEnabled()) return ()=>{};
|
|
402
|
+
const isActTool = options?.toolName === 'act';
|
|
403
|
+
const screenshotExportCache = new Map();
|
|
404
|
+
if (isActTool && 'function' == typeof agent.addProgressListener) return agent.addProgressListener((event)=>{
|
|
405
|
+
const match = progressRendererForEvent(event);
|
|
406
|
+
if (!match) return;
|
|
407
|
+
const context = getCliVerboseContext();
|
|
408
|
+
const isTextMode = 'jsonl' !== context.format;
|
|
409
|
+
const progress = match.renderer.normalize(event, {
|
|
410
|
+
reportFile: agent.reportFile,
|
|
411
|
+
exportMode: isTextMode ? 'report' : 'none',
|
|
412
|
+
cache: screenshotExportCache
|
|
413
|
+
});
|
|
414
|
+
if (!progress) return;
|
|
415
|
+
emitCliVerboseEvent({
|
|
416
|
+
event: 'agent_progress',
|
|
417
|
+
tool: options?.toolName,
|
|
418
|
+
scope: match.scope,
|
|
419
|
+
progress
|
|
420
|
+
});
|
|
421
|
+
});
|
|
422
|
+
if (isActTool) return ()=>{};
|
|
423
|
+
if ('function' != typeof agent.addDumpUpdateListener) return ()=>{};
|
|
424
|
+
return agent.addDumpUpdateListener((_dump, executionDump)=>{
|
|
425
|
+
const context = getCliVerboseContext();
|
|
426
|
+
const isTextMode = 'jsonl' !== context.format;
|
|
427
|
+
const summaryExportMode = isTextMode && !isActTool ? 'tmp' : 'none';
|
|
428
|
+
const summary = summarizeDumpUpdate(executionDump, {
|
|
429
|
+
exportMode: summaryExportMode,
|
|
430
|
+
cache: screenshotExportCache
|
|
431
|
+
});
|
|
432
|
+
if (!summary) return;
|
|
433
|
+
emitCliVerboseEvent({
|
|
434
|
+
event: 'dump_update',
|
|
435
|
+
tool: options?.toolName,
|
|
436
|
+
report: agent.reportFile || void 0,
|
|
437
|
+
...summary
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
exports.attachCliVerboseDumpListener = __webpack_exports__.attachCliVerboseDumpListener;
|
|
442
|
+
exports.cliVerboseErrorMessage = __webpack_exports__.cliVerboseErrorMessage;
|
|
443
|
+
exports.cliVerboseFlag = __webpack_exports__.cliVerboseFlag;
|
|
444
|
+
exports.compactCliVerboseArgs = __webpack_exports__.compactCliVerboseArgs;
|
|
445
|
+
exports.compactCliVerboseValue = __webpack_exports__.compactCliVerboseValue;
|
|
446
|
+
exports.emitCliVerboseEvent = __webpack_exports__.emitCliVerboseEvent;
|
|
447
|
+
exports.getCliVerboseContext = __webpack_exports__.getCliVerboseContext;
|
|
448
|
+
exports.isCliVerboseEnabled = __webpack_exports__.isCliVerboseEnabled;
|
|
449
|
+
exports.stripVerboseFlag = __webpack_exports__.stripVerboseFlag;
|
|
450
|
+
exports.withCliVerboseContext = __webpack_exports__.withCliVerboseContext;
|
|
451
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
452
|
+
"attachCliVerboseDumpListener",
|
|
453
|
+
"cliVerboseErrorMessage",
|
|
454
|
+
"cliVerboseFlag",
|
|
455
|
+
"compactCliVerboseArgs",
|
|
456
|
+
"compactCliVerboseValue",
|
|
457
|
+
"emitCliVerboseEvent",
|
|
458
|
+
"getCliVerboseContext",
|
|
459
|
+
"isCliVerboseEnabled",
|
|
460
|
+
"stripVerboseFlag",
|
|
461
|
+
"withCliVerboseContext"
|
|
462
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
463
|
+
Object.defineProperty(exports, '__esModule', {
|
|
464
|
+
value: true
|
|
465
|
+
});
|
|
@@ -57,8 +57,8 @@ aiQuery<T>(queryObject: Record<string, string>): Promise<T> // Extracts data fro
|
|
|
57
57
|
// The following is test code for Midscene AI, for reference
|
|
58
58
|
// The following is Playwright syntax, you can use Playwright to assist in test generation
|
|
59
59
|
import { test as base } from '@playwright/test';
|
|
60
|
-
import type { PlayWrightAiFixtureType } from '@
|
|
61
|
-
import { PlaywrightAiFixture } from '@
|
|
60
|
+
import type { PlayWrightAiFixtureType } from '@aiscene/web/playwright';
|
|
61
|
+
import { PlaywrightAiFixture } from '@aiscene/web/playwright';
|
|
62
62
|
|
|
63
63
|
const test = base.extend<PlayWrightAiFixtureType>(PlaywrightAiFixture({
|
|
64
64
|
waitForNetworkIdleTimeout: 2000, // optional, the timeout for waiting for network idle between each action, default is 2000ms
|
|
@@ -25,17 +25,22 @@ var __webpack_exports__ = {};
|
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
DEFAULT_WAIT_FOR_NAVIGATION_TIMEOUT: ()=>DEFAULT_WAIT_FOR_NAVIGATION_TIMEOUT,
|
|
28
|
-
|
|
28
|
+
SCRCPY_PUSH_TIMEOUT_MS: ()=>SCRCPY_PUSH_TIMEOUT_MS,
|
|
29
29
|
CONTAINER_MINI_WIDTH: ()=>CONTAINER_MINI_WIDTH,
|
|
30
30
|
DEFAULT_WAIT_FOR_NETWORK_IDLE_CONCURRENCY: ()=>DEFAULT_WAIT_FOR_NETWORK_IDLE_CONCURRENCY,
|
|
31
31
|
DEFAULT_WAIT_FOR_NETWORK_IDLE_TIMEOUT: ()=>DEFAULT_WAIT_FOR_NETWORK_IDLE_TIMEOUT,
|
|
32
|
-
PLAYGROUND_SERVER_PORT: ()=>PLAYGROUND_SERVER_PORT,
|
|
33
32
|
TEXT_MAX_SIZE: ()=>TEXT_MAX_SIZE,
|
|
33
|
+
SCRCPY_PREVIEW_METADATA_TIMEOUT_MS: ()=>SCRCPY_PREVIEW_METADATA_TIMEOUT_MS,
|
|
34
34
|
WEBDRIVER_ELEMENT_ID_KEY: ()=>WEBDRIVER_ELEMENT_ID_KEY,
|
|
35
|
+
YAML_EXAMPLE_CODE: ()=>external_example_code_js_namespaceObject.YAML_EXAMPLE_CODE,
|
|
36
|
+
CONTAINER_MINI_HEIGHT: ()=>CONTAINER_MINI_HEIGHT,
|
|
37
|
+
SCRCPY_VIDEO_STREAM_TIMEOUT_MS: ()=>SCRCPY_VIDEO_STREAM_TIMEOUT_MS,
|
|
38
|
+
SCRCPY_ADB_CONNECT_TIMEOUT_MS: ()=>SCRCPY_ADB_CONNECT_TIMEOUT_MS,
|
|
39
|
+
SCRCPY_START_TIMEOUT_MS: ()=>SCRCPY_START_TIMEOUT_MS,
|
|
40
|
+
PLAYGROUND_SERVER_PORT: ()=>PLAYGROUND_SERVER_PORT,
|
|
35
41
|
DEFAULT_WDA_PORT: ()=>DEFAULT_WDA_PORT,
|
|
36
42
|
NodeType: ()=>constants_NodeType,
|
|
37
43
|
PLAYWRIGHT_EXAMPLE_CODE: ()=>external_example_code_js_namespaceObject.PLAYWRIGHT_EXAMPLE_CODE,
|
|
38
|
-
CONTAINER_MINI_HEIGHT: ()=>CONTAINER_MINI_HEIGHT,
|
|
39
44
|
SCRCPY_SERVER_PORT: ()=>SCRCPY_SERVER_PORT,
|
|
40
45
|
TEXT_SIZE_THRESHOLD: ()=>TEXT_SIZE_THRESHOLD
|
|
41
46
|
});
|
|
@@ -56,6 +61,11 @@ var constants_NodeType = /*#__PURE__*/ function(NodeType) {
|
|
|
56
61
|
}({});
|
|
57
62
|
const PLAYGROUND_SERVER_PORT = 5800;
|
|
58
63
|
const SCRCPY_SERVER_PORT = 5700;
|
|
64
|
+
const SCRCPY_ADB_CONNECT_TIMEOUT_MS = 10000;
|
|
65
|
+
const SCRCPY_PUSH_TIMEOUT_MS = 10000;
|
|
66
|
+
const SCRCPY_START_TIMEOUT_MS = 15000;
|
|
67
|
+
const SCRCPY_VIDEO_STREAM_TIMEOUT_MS = 15000;
|
|
68
|
+
const SCRCPY_PREVIEW_METADATA_TIMEOUT_MS = SCRCPY_ADB_CONNECT_TIMEOUT_MS + SCRCPY_PUSH_TIMEOUT_MS + SCRCPY_START_TIMEOUT_MS + SCRCPY_VIDEO_STREAM_TIMEOUT_MS + 5000;
|
|
59
69
|
const WEBDRIVER_ELEMENT_ID_KEY = 'element-6066-11e4-a52e-4f735466cecf';
|
|
60
70
|
const DEFAULT_WDA_PORT = 8100;
|
|
61
71
|
const DEFAULT_WAIT_FOR_NAVIGATION_TIMEOUT = 5000;
|
|
@@ -70,7 +80,12 @@ exports.DEFAULT_WDA_PORT = __webpack_exports__.DEFAULT_WDA_PORT;
|
|
|
70
80
|
exports.NodeType = __webpack_exports__.NodeType;
|
|
71
81
|
exports.PLAYGROUND_SERVER_PORT = __webpack_exports__.PLAYGROUND_SERVER_PORT;
|
|
72
82
|
exports.PLAYWRIGHT_EXAMPLE_CODE = __webpack_exports__.PLAYWRIGHT_EXAMPLE_CODE;
|
|
83
|
+
exports.SCRCPY_ADB_CONNECT_TIMEOUT_MS = __webpack_exports__.SCRCPY_ADB_CONNECT_TIMEOUT_MS;
|
|
84
|
+
exports.SCRCPY_PREVIEW_METADATA_TIMEOUT_MS = __webpack_exports__.SCRCPY_PREVIEW_METADATA_TIMEOUT_MS;
|
|
85
|
+
exports.SCRCPY_PUSH_TIMEOUT_MS = __webpack_exports__.SCRCPY_PUSH_TIMEOUT_MS;
|
|
73
86
|
exports.SCRCPY_SERVER_PORT = __webpack_exports__.SCRCPY_SERVER_PORT;
|
|
87
|
+
exports.SCRCPY_START_TIMEOUT_MS = __webpack_exports__.SCRCPY_START_TIMEOUT_MS;
|
|
88
|
+
exports.SCRCPY_VIDEO_STREAM_TIMEOUT_MS = __webpack_exports__.SCRCPY_VIDEO_STREAM_TIMEOUT_MS;
|
|
74
89
|
exports.TEXT_MAX_SIZE = __webpack_exports__.TEXT_MAX_SIZE;
|
|
75
90
|
exports.TEXT_SIZE_THRESHOLD = __webpack_exports__.TEXT_SIZE_THRESHOLD;
|
|
76
91
|
exports.WEBDRIVER_ELEMENT_ID_KEY = __webpack_exports__.WEBDRIVER_ELEMENT_ID_KEY;
|
|
@@ -85,7 +100,12 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
85
100
|
"NodeType",
|
|
86
101
|
"PLAYGROUND_SERVER_PORT",
|
|
87
102
|
"PLAYWRIGHT_EXAMPLE_CODE",
|
|
103
|
+
"SCRCPY_ADB_CONNECT_TIMEOUT_MS",
|
|
104
|
+
"SCRCPY_PREVIEW_METADATA_TIMEOUT_MS",
|
|
105
|
+
"SCRCPY_PUSH_TIMEOUT_MS",
|
|
88
106
|
"SCRCPY_SERVER_PORT",
|
|
107
|
+
"SCRCPY_START_TIMEOUT_MS",
|
|
108
|
+
"SCRCPY_VIDEO_STREAM_TIMEOUT_MS",
|
|
89
109
|
"TEXT_MAX_SIZE",
|
|
90
110
|
"TEXT_SIZE_THRESHOLD",
|
|
91
111
|
"WEBDRIVER_ELEMENT_ID_KEY",
|
|
@@ -52,14 +52,17 @@ class ModelConfigManager {
|
|
|
52
52
|
this.modelConfigMap = {
|
|
53
53
|
default: {
|
|
54
54
|
...defaultConfig,
|
|
55
|
+
intent: 'default',
|
|
55
56
|
createOpenAIClient: this.createOpenAIClientFn
|
|
56
57
|
},
|
|
57
58
|
insight: {
|
|
58
59
|
...insightConfig || defaultConfig,
|
|
60
|
+
intent: 'insight',
|
|
59
61
|
createOpenAIClient: this.createOpenAIClientFn
|
|
60
62
|
},
|
|
61
63
|
planning: {
|
|
62
64
|
...planningConfig || defaultConfig,
|
|
65
|
+
intent: 'planning',
|
|
63
66
|
createOpenAIClient: this.createOpenAIClientFn
|
|
64
67
|
}
|
|
65
68
|
};
|
|
@@ -36,6 +36,9 @@ const external_logger_js_namespaceObject = require("../logger.js");
|
|
|
36
36
|
const external_utils_js_namespaceObject = require("../utils.js");
|
|
37
37
|
const external_helper_js_namespaceObject = require("./helper.js");
|
|
38
38
|
const external_init_debug_js_namespaceObject = require("./init-debug.js");
|
|
39
|
+
const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-common-config.html';
|
|
40
|
+
const getCurrentVersion = ()=>"8.0.4";
|
|
41
|
+
const getInvalidModelFamilyMessage = (modelFamily)=>`Invalid MIDSCENE_MODEL_FAMILY value: ${modelFamily}. Current version v${getCurrentVersion()} accepts the following model families: ${external_types_js_namespaceObject.MODEL_FAMILY_VALUES.join(', ')}. You can also visit ${MODEL_CONFIG_DOC_URL} for the latest configuration information.`;
|
|
39
42
|
const KEYS_MAP = {
|
|
40
43
|
insight: external_constants_js_namespaceObject.INSIGHT_MODEL_CONFIG_KEYS,
|
|
41
44
|
planning: external_constants_js_namespaceObject.PLANNING_MODEL_CONFIG_KEYS,
|
|
@@ -46,7 +49,7 @@ const getUITarsModelVersion = (modelFamily)=>{
|
|
|
46
49
|
if ('vlm-ui-tars-doubao' === modelFamily || 'vlm-ui-tars-doubao-1.5' === modelFamily) return external_types_js_namespaceObject.UITarsModelVersion.DOUBAO_1_5_20B;
|
|
47
50
|
};
|
|
48
51
|
const validateModelFamily = (modelFamily)=>{
|
|
49
|
-
if (modelFamily && !external_types_js_namespaceObject.MODEL_FAMILY_VALUES.includes(modelFamily)) throw new Error(
|
|
52
|
+
if (modelFamily && !external_types_js_namespaceObject.MODEL_FAMILY_VALUES.includes(modelFamily)) throw new Error(getInvalidModelFamilyMessage(modelFamily));
|
|
50
53
|
};
|
|
51
54
|
const legacyConfigToModelFamily = (provider)=>{
|
|
52
55
|
const isDoubao = provider[external_types_js_namespaceObject.MIDSCENE_USE_DOUBAO_VISION];
|
|
@@ -122,6 +125,7 @@ const parseOpenaiSdkConfig = ({ keys, provider, useLegacyLogic = false })=>{
|
|
|
122
125
|
modelName: modelName,
|
|
123
126
|
modelDescription,
|
|
124
127
|
intent: '-',
|
|
128
|
+
slot: '-',
|
|
125
129
|
timeout: provider[keys.timeout] ? Number(provider[keys.timeout]) : void 0,
|
|
126
130
|
temperature,
|
|
127
131
|
retryCount: (()=>{
|
|
@@ -164,6 +168,7 @@ const decideModelConfigFromIntentConfig = (intent, configMap)=>{
|
|
|
164
168
|
useLegacyLogic: 'default' === intent
|
|
165
169
|
});
|
|
166
170
|
finalResult.intent = intent;
|
|
171
|
+
finalResult.slot = intent;
|
|
167
172
|
debugLog('decideModelConfig result by agent.modelConfig() with intent', intent, (0, external_helper_js_namespaceObject.maskConfig)({
|
|
168
173
|
...finalResult
|
|
169
174
|
}));
|
package/dist/lib/env/types.js
CHANGED
|
@@ -36,6 +36,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
36
36
|
MIDSCENE_ANDROID_IME_STRATEGY: ()=>MIDSCENE_ANDROID_IME_STRATEGY,
|
|
37
37
|
MIDSCENE_CACHE: ()=>MIDSCENE_CACHE,
|
|
38
38
|
MIDSCENE_CACHE_MAX_FILENAME_LENGTH: ()=>MIDSCENE_CACHE_MAX_FILENAME_LENGTH,
|
|
39
|
+
MIDSCENE_CHROME_PATH: ()=>MIDSCENE_CHROME_PATH,
|
|
39
40
|
MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG: ()=>MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG,
|
|
40
41
|
MIDSCENE_DEBUG_MODE: ()=>MIDSCENE_DEBUG_MODE,
|
|
41
42
|
MIDSCENE_DEBUG_MODEL_PROFILE: ()=>MIDSCENE_DEBUG_MODEL_PROFILE,
|
|
@@ -55,6 +56,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
55
56
|
MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY: ()=>MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY,
|
|
56
57
|
MIDSCENE_INSIGHT_MODEL_TEMPERATURE: ()=>MIDSCENE_INSIGHT_MODEL_TEMPERATURE,
|
|
57
58
|
MIDSCENE_INSIGHT_MODEL_TIMEOUT: ()=>MIDSCENE_INSIGHT_MODEL_TIMEOUT,
|
|
59
|
+
MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE: ()=>MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE,
|
|
58
60
|
MIDSCENE_IOS_DEVICE_UDID: ()=>MIDSCENE_IOS_DEVICE_UDID,
|
|
59
61
|
MIDSCENE_IOS_SIMULATOR_UDID: ()=>MIDSCENE_IOS_SIMULATOR_UDID,
|
|
60
62
|
MIDSCENE_LANGFUSE_DEBUG: ()=>MIDSCENE_LANGFUSE_DEBUG,
|
|
@@ -125,6 +127,7 @@ const MIDSCENE_DEBUG_MODEL_RESPONSE = 'MIDSCENE_DEBUG_MODEL_RESPONSE';
|
|
|
125
127
|
const MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG = 'MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG';
|
|
126
128
|
const MIDSCENE_DEBUG_MODE = 'MIDSCENE_DEBUG_MODE';
|
|
127
129
|
const MIDSCENE_MCP_USE_PUPPETEER_MODE = 'MIDSCENE_MCP_USE_PUPPETEER_MODE';
|
|
130
|
+
const MIDSCENE_CHROME_PATH = 'MIDSCENE_CHROME_PATH';
|
|
128
131
|
const MIDSCENE_MCP_CHROME_PATH = 'MIDSCENE_MCP_CHROME_PATH';
|
|
129
132
|
const MIDSCENE_MCP_ANDROID_MODE = 'MIDSCENE_MCP_ANDROID_MODE';
|
|
130
133
|
const DOCKER_CONTAINER = 'DOCKER_CONTAINER';
|
|
@@ -154,6 +157,7 @@ const MIDSCENE_ADB_REMOTE_PORT = 'MIDSCENE_ADB_REMOTE_PORT';
|
|
|
154
157
|
const MIDSCENE_ANDROID_IME_STRATEGY = 'MIDSCENE_ANDROID_IME_STRATEGY';
|
|
155
158
|
const MIDSCENE_IOS_DEVICE_UDID = 'MIDSCENE_IOS_DEVICE_UDID';
|
|
156
159
|
const MIDSCENE_IOS_SIMULATOR_UDID = 'MIDSCENE_IOS_SIMULATOR_UDID';
|
|
160
|
+
const MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE = 'MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE';
|
|
157
161
|
const MIDSCENE_CACHE = 'MIDSCENE_CACHE';
|
|
158
162
|
const MIDSCENE_USE_VLM_UI_TARS = 'MIDSCENE_USE_VLM_UI_TARS';
|
|
159
163
|
const MIDSCENE_USE_QWEN_VL = 'MIDSCENE_USE_QWEN_VL';
|
|
@@ -233,6 +237,7 @@ const STRING_ENV_KEYS = [
|
|
|
233
237
|
MIDSCENE_REPORT_TAG_NAME,
|
|
234
238
|
MIDSCENE_PREFERRED_LANGUAGE,
|
|
235
239
|
MATCH_BY_POSITION,
|
|
240
|
+
MIDSCENE_CHROME_PATH,
|
|
236
241
|
MIDSCENE_MCP_CHROME_PATH,
|
|
237
242
|
DOCKER_CONTAINER
|
|
238
243
|
];
|
|
@@ -340,6 +345,7 @@ exports.MIDSCENE_ADB_REMOTE_PORT = __webpack_exports__.MIDSCENE_ADB_REMOTE_PORT;
|
|
|
340
345
|
exports.MIDSCENE_ANDROID_IME_STRATEGY = __webpack_exports__.MIDSCENE_ANDROID_IME_STRATEGY;
|
|
341
346
|
exports.MIDSCENE_CACHE = __webpack_exports__.MIDSCENE_CACHE;
|
|
342
347
|
exports.MIDSCENE_CACHE_MAX_FILENAME_LENGTH = __webpack_exports__.MIDSCENE_CACHE_MAX_FILENAME_LENGTH;
|
|
348
|
+
exports.MIDSCENE_CHROME_PATH = __webpack_exports__.MIDSCENE_CHROME_PATH;
|
|
343
349
|
exports.MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG = __webpack_exports__.MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG;
|
|
344
350
|
exports.MIDSCENE_DEBUG_MODE = __webpack_exports__.MIDSCENE_DEBUG_MODE;
|
|
345
351
|
exports.MIDSCENE_DEBUG_MODEL_PROFILE = __webpack_exports__.MIDSCENE_DEBUG_MODEL_PROFILE;
|
|
@@ -359,6 +365,7 @@ exports.MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL = __webpack_exports__.MIDSCENE_INS
|
|
|
359
365
|
exports.MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY = __webpack_exports__.MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY;
|
|
360
366
|
exports.MIDSCENE_INSIGHT_MODEL_TEMPERATURE = __webpack_exports__.MIDSCENE_INSIGHT_MODEL_TEMPERATURE;
|
|
361
367
|
exports.MIDSCENE_INSIGHT_MODEL_TIMEOUT = __webpack_exports__.MIDSCENE_INSIGHT_MODEL_TIMEOUT;
|
|
368
|
+
exports.MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE = __webpack_exports__.MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE;
|
|
362
369
|
exports.MIDSCENE_IOS_DEVICE_UDID = __webpack_exports__.MIDSCENE_IOS_DEVICE_UDID;
|
|
363
370
|
exports.MIDSCENE_IOS_SIMULATOR_UDID = __webpack_exports__.MIDSCENE_IOS_SIMULATOR_UDID;
|
|
364
371
|
exports.MIDSCENE_LANGFUSE_DEBUG = __webpack_exports__.MIDSCENE_LANGFUSE_DEBUG;
|
|
@@ -433,6 +440,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
433
440
|
"MIDSCENE_ANDROID_IME_STRATEGY",
|
|
434
441
|
"MIDSCENE_CACHE",
|
|
435
442
|
"MIDSCENE_CACHE_MAX_FILENAME_LENGTH",
|
|
443
|
+
"MIDSCENE_CHROME_PATH",
|
|
436
444
|
"MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG",
|
|
437
445
|
"MIDSCENE_DEBUG_MODE",
|
|
438
446
|
"MIDSCENE_DEBUG_MODEL_PROFILE",
|
|
@@ -452,6 +460,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
452
460
|
"MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY",
|
|
453
461
|
"MIDSCENE_INSIGHT_MODEL_TEMPERATURE",
|
|
454
462
|
"MIDSCENE_INSIGHT_MODEL_TIMEOUT",
|
|
463
|
+
"MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE",
|
|
455
464
|
"MIDSCENE_IOS_DEVICE_UDID",
|
|
456
465
|
"MIDSCENE_IOS_SIMULATOR_UDID",
|
|
457
466
|
"MIDSCENE_LANGFUSE_DEBUG",
|